debug error on '.edit' statement

C

CityGuy

Hi,

I'm fairly new at VBA programming. I have run into a snag.

I want to use code to save edited data from unbound text boxes. The
following code fragment causes an error when I try to compile the module.

Error:
"Compile Error, Method or data member not found"

Code:
With SdrInfo
'
.Edit <----------- Debugger highlights this line
 
C

CityGuy

Hi,

Sorry, SdrInfo is a recordset. I open it with

Set db = CurrentDb()
Set SdrInfo = db.OpenRecordset("tblSdrInspectionInfo", dbOpenDynaset)
 
C

CityGuy

I should also add that SdrInfo references a table residing on the
back end of this database
 
C

CityGuy

Hi,

Thanks for the tip. How does one know if a database is an ADO or DAO.
I still find the differeneces between these 2 confusing.
 
D

Duane Hookom

Your code should be something like:
Dim db as DAO.Database
Dim SdrInfo As DAO.Recordset
Set db = CurrentDb()
Set SdrInfo = db.OpenRecordset("tblSdrInspectionInfo", dbOpenDynaset)

This code explicitly uses the DAO library which has been around in Access
for more years than ADO. DAO IMHO works best for Access tables.
 
B

Brendan Reynolds

The OpenRecordset method of the DAO Database object will always return a DAO
Recordset, so if SdrInfo was anything other than a DAO Recordset, I'd expect
a Type Mismatch error on the line that calls OpenRecordset. I think you may
need to post more of the code before we can see what the problem is.
 
D

Dirk Goldgar

Brendan Reynolds said:
The OpenRecordset method of the DAO Database object will always
return a DAO Recordset, so if SdrInfo was anything other than a DAO
Recordset, I'd expect a Type Mismatch error on the line that calls
OpenRecordset. I think you may need to post more of the code before
we can see what the problem is.

I don't think the "type mismatch" error will be raised until run time.
The "method or data member not found" error will be raised at compile
time, which is what CityGuy is reporting.
 
C

CityGuy

Adding the "DAO." fixed the problem. Thanks for the help.
Where can I get some good reference material on the differences
between the ADO and DAO?
 
Top