How do I enable DAO in Access 2003

Theguyinthehat

Registered User.
Local time
Today, 02:09
Joined
Aug 17, 2009
Messages
46
I still can't compile with the line
dim rst as DAO.Recordset

and I've looked everywhere for a way to 'enable' DAO without any luck. Can anyone help me out?
 
In the VBA window you go to TOOLS > REFERENCES and the scroll down until you find

Microsoft DAO 3.51

or

Microsoft DAO 3.6

and check the box next to it.
 
Actually that would be

Microsoft DAO 3.51 Object Library

or

Microsoft DAO 3.6 Object Library
 
if you dont want to have to qualify your references with dao, you just need to make sure that the reference for DAO is above the one for ADO (activex data objects)
 
gemma-

While this is true that ordering can avoid the extra typing, it can be worse if the references gets broken. For example, suppose we put the file on computer that didn't have DAO library (at least not the same version) but happened to have the correct version for ADO. What would happen is that the program seems to run okay then bugs associating with accessing DAO methods that's not available in ADO start showing up. This could be more time consuming and confusing than getting a broken reference right at the start, alerting the user/developer to the problem and fixing it accordingly.
 
I would always be explicit. It doesn't matter that it might not need to be, but it is good practice to explicitly declare them. Of course you could just use late binding too and then you don't need to use either.
 
For DAO, there's also a different way that requires neither early/late binding or explicit references; ChrisO demonstrated it, I think.

Code:
With CurrentDb.OpenRecordset("SELECT ...")
   ...
End With

Supposedly, it'd always succeed since we're walking the DAO object model. I don't think we can do the same thing with ADO, though.
 

Users who are viewing this thread

Back
Top Bottom