ACC: "User-defined Type Not Defined" Error Message

ID: Q182342


The information in this article applies to:
  • Microsoft Access versions 7.0, 97


SYMPTOMS

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

When you compile or run code, you may receive the following error message:

Compile Error: User-defined type not defined.


CAUSE

You are referring to an object in an object library that you do not have referenced.


RESOLUTION

You must add a reference to the object library that contains the object that you are using in code. To do so, follow these steps:

  1. Open any module in the database that is generating the error described in the "Symptoms" section of this article.


  2. On the Debug menu, click Compile All Modules. Note the line of code that is highlighted when you receive the error message.


  3. On the Tools menu, click References.


  4. Click to select the object library that contains the object referenced by the line of code that is highlighted.



MORE INFORMATION

One of the most common object libraries that may cause the error described in the "Symptoms" section if it is not referenced is the Microsoft DAO Object Library. If the reference is missing, you may receive this error on many common DAO commands such as:

Dim db as Database

If you receive this error on a common DAO object, you need to add the appropriate reference for your version of Microsoft Access:
In Microsoft Access 97: Microsoft DAO 3.5 Object Library
In Microsoft Access 7.0: Microsoft DAO 3.0 Object Library

NOTE: If you are using the older versions of DAO objects, methods, and properties in your application, you must establish a reference to the Microsoft DAO 2.5/3.x compatibility library instead.

Steps to Reproduce Behavior


  1. Create a module and type the following procedure:
    
          Function Test()
             Dim db as Database
          End Function 


  2. On the Tools menu, click to clear the Microsoft DAO Object Library.


  3. To test this function, type the following line in the Debug window, and then press ENTER.

    ?Test()

    Note that you receive the error message mentioned in the "Symptoms" section.


Keywords : MdlDao PgmOthr
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: April 27, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.