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.

XL2000: You Receive "User-Defined Type Not Defined" Error Message When Using Data Access Objects


View products that this article applies to.

Symptoms

When you run a Microsoft Visual Basic for Applications subroutine using data access objects (DAOs), you may receive one of the following compile error messages:
User-Defined Type Not Defined
-or-
Sub or Function Not Defined

↑ Back to the top


Cause

You may receive the error message when a subroutine contains code that uses the Microsoft DAO Object Library, and the library is not referenced.

↑ Back to the top


Resolution

To avoid the error message, follow these steps:
  1. In the Visual Basic Editor, click References on the Tools menu.
  2. In the References dialog box, under Available References, select Microsoft DAO 3.5 Object Library, and then click OK.

    If Microsoft DAO 3.5 Object Library is not listed in the list box under Available References, click Browse, and then navigate to the Dao350.dll file. It should be found in the following location:
    \Program Files\Common Files\Microsoft Shared\Dao\Dao350.dll
    Select the file, and then click OK. This returns you to the References dialog box. Click OK.

↑ Back to the top


More information

When you run a subroutine using DAO, and the DAO Object Library is not referenced, you receive one of the messages listed in the "Symptoms" section, depending on what code is written. If your code declares variables, for example
Dim Db as Database
Dim Rs as Recordset
you receive the
User-Defined Type Not Defined
error message, and the subroutine fails in the variable declaration section.

If you did not declare your variables, you receive the following error message
Sub or Function Not Defined
and the subroutine fails at the first use of a statement that requires the DAO Object Library. This line is usually:
Set Db = Workspaces(0).OpenDatabase(Path, optional arguments)
In this case, the subroutine fails when it encounters the "Workspaces" term.

↑ Back to the top


Keywords: KB213353, kbprogramming, kbprb, kberrmsg

↑ Back to the top

Article Info
Article ID : 213353
Revision : 6
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 231