Microsoft DAO 3.6 and ADO 2.1 have several object names in common, such as
Errors and
Recordset. If you reference both DAO 3.6 and ADO 2.1, and you do not specify which library you are using to declare an object, your code may cause an error or not run as expected. To specifically declare an object in a library, use the prefix for the library. For example, the following lines declare a variable as a database:
Using DAO 3.6
Dim MyRst as DAO.Recordset
Using ADO 2.1
Dim MyRst as ADODB.Recordset
By always using a prefix to define which library your objects are being declared in, you can eliminate possible errors caused by objects being declared from the wrong library. Using the prefix also makes your code easier to read.
Converted databases automatically update the Microsoft DAO 3.x reference to Microsoft DAO 3.6.
To manually include the reference to the DAO 3.6 Object library, follow these steps:
- Open a new Access database.
- Click Modules under Objects, and then click New.
- In the Visual Basic Editor, click References on the Tools menu.
- Scroll through the list until you find the Microsoft DAO 3.6 Object Library, and click to select the reference.
- Click OK.
- On the File menu, click Close and Return to Microsoft Access.