PRB: ADO: Compile Error: User-Defined Type Not Defined

ID: Q184609


The information in this article applies to:


SYMPTOMS

When you compile your ADO project, you receive the following error:

Compile error: User-defined type not defined
This can occur on either a Connection or Command object.


CAUSE

You may have referenced one of the following libraries instead of the Microsoft ActiveX Data Objects (ADODB) type library:


RESOLUTION

Remove the incorrect type library reference from your project, and add a reference to the correct type library.


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new project and add a command button (Command1) to a form.


  2. Add a reference to the Microsoft ActiveX Data Objects Recordset Library.


  3. Add the following code to the form:


  4. 
       Private Sub Command1_Click()
       Dim cn As Connection
       End Sub 
  5. Run the project and click the command button. The error appears.


  6. Remove the reference, and add a reference to the Microsoft ActiveX Data Objects Library.


  7. Click the command button. The error does not appear.


NOTE:

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Malcolm Stewart, Microsoft Corporation.

Additional query words:


Keywords          : kbnokeyword kbADO150 kbADO200 kbVBp500 kbVBp600 
Version           : WINDOWS:1.5,2.0,5.0,6.0
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: April 21, 1999