Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

New Access databases do not include reference to DAO object library in Access


View products that this article applies to.

Symptoms

By default, a new Microsoft Access database does not reference the Microsoft DAO 3.6 Object Library. This is a change from versions of Access that are earlier than Access 2000.

If you run Visual Basic for Applications code that uses the Data Access Object (DAO) library in a new Access database, you receive an error message that is similar to the following:

Error message 1
Compile error:
User-defined type not defined.
Error message 2
Run-time error '424':
Object required.
Error message 3
Run time error '13':
Type mismatch

↑ Back to the top


Resolution

Developers who want to use the Data Access Object (DAO) library instead of, or in addition to, the new Microsoft ActiveX Data Object (ADO) model, must manually set the reference in each new database.

↑ Back to the top


More information

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:
  1. Open a new Access database.
  2. Click Modules under Objects, and then click New.
  3. In the Visual Basic Editor, click References on the Tools menu.
  4. Scroll through the list until you find the Microsoft DAO 3.6 Object Library, and click to select the reference.
  5. Click OK.
  6. On the File menu, click Close and Return to Microsoft Access.

↑ Back to the top


References

For more information about the new Microsoft ActiveX Data Object (ADO) model, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type using ActiveX Data Objects in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB225962, kbdao, kbado, kbprb, kbdatabase, kbnofix, kbinfo

↑ Back to the top

Article Info
Article ID : 225962
Revision : 4
Created on : 8/2/2004
Published on : 8/2/2004
Exists online : False
Views : 462