Microsoft KB Archive/283883

= ACC2002: New Access Databases Do Not Include Reference to Microsoft DAO Object Library =

PSS ID Number: 283883

Article Last Modified on 11/6/2003

-

The information in this article applies to:


 * Microsoft Access 2002

-



This article was previously published under Q283883



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).

For a Microsoft Access 2000 version of this article, see 225962.



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

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

Compile error:

User-defined type not defined.

-or-

Run-time error '424':

Object required.



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



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

You must always use a prefix to define which library your objects are declared in. This prevents possible errors that are caused by objects that are declared from the wrong library. When you use the prefix, your code is also 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 2002 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 Microsoft DAO 3.6 Object Library, and then click to select the reference.
 * 5) Click OK.
 * 6) On the File menu, click Close and Return to Microsoft Access.

