Microsoft KB Archive/184609

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

Article ID: 184609

Article Last Modified on 8/23/2001

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.1 Service Pack 2
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7

-



This article was previously published under Q184609



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:
 * Microsoft ActiveX Data Objects Recordset (ADOR) type library.

-or-
 * Microsoft ActiveX Data Objects (Multi-dimensional) (ADOMD) 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.



Steps to Reproduce Behavior
 Create a new project and add a command button (Command1) to a form. Add a reference to the Microsoft ActiveX Data Objects Recordset Library.  Add the following code to the form: Private Sub Command1_Click Dim cn As ADODB.Connection End Sub  Run the project and click the command button. The error appears. Remove the reference, and add a reference to the Microsoft ActiveX Data Objects Library.</li> Click the command button. The error does not appear.</li></ol>

NOTE:
 * Microsoft Access users will have to use ADODB.Connection to avoid confusion with the DAO Connection object.
 * If the Intellitype feature is turned on, you should notice that it does not show Connection as a valid object with the ADOR type library, but does with the ADODB type library. This is a good indication that you do not have the correct type library referenced.
 * This error can also occur when referencing objects in other type libraries that aren't referenced.

Keywords: kbprb KB184609

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.