Method or Data member not found

L

LAF

I have a module in a database that used to run fine. I imported two tables
into the database and incorporated them into the module. Now when I run the
module I get a compile error that the method or data member was not found.
The code I used:

Dim db As DAO.database
Dim rst2 As Recordset
Set db=CurrentDb()
Set rst2=db.OpenRecordset("tblAllCapSight", dbOpenDynaset)
rst2.Sort = "[BANDNUM],[EvDate]"
Set rst2=rst2.OpenRecordset

The compile error is highlighted on the rst2.OpenRecordset on the last line.
I have double checked the table and the fields, and they are accurately
entered in the code.
 
P

PieterLinden via AccessMonster.com

LAF said:
I have a module in a database that used to run fine. I imported two tables
into the database and incorporated them into the module. Now when I run the
module I get a compile error that the method or data member was not found.
The code I used:

Dim db As DAO.database
Dim rst2 As Recordset
Set db=CurrentDb()
Set rst2=db.OpenRecordset("tblAllCapSight", dbOpenDynaset)
rst2.Sort = "[BANDNUM],[EvDate]"
Set rst2=rst2.OpenRecordset

The compile error is highlighted on the rst2.OpenRecordset on the last line.
I have double checked the table and the fields, and they are accurately
entered in the code.

the line
Dim rst2 As Recordset

is defaulting to an ADO type recordset, not a DAO recordset. so when you use
the DAO database object to open the recordset, you're mixing libraries.
Declare rst2 as a DAO.Recordset and it should work fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top