Fix the ADODB.Recordset User-Defined Type Error in Access VBA
Question details
Resolve an Access VBA user-defined type error involving an ADO Recordset declaration.

- Product
- Microsoft Access VBA
- Device & OS
- not provided
- Scenario
- A database uses ADO Recordset objects and may also reference DAO objects.
- Observed behavior
- Access reports a user-defined type error, or an unqualified Recordset declaration may resolve to the wrong library.
Open the affected database in Microsoft Access and identify the declaration that causes the error. Make sure you can open the VBA editor and access Tools > References.
Enable the ADO reference and qualify Recordset declarations
Use this solution when Access cannot recognize ADODB.Recordset or may confuse ADO and DAO Recordset types.
In Access, press Alt+F11 to open the VBA editor for the affected database.
Select Tools > References, check an available Microsoft ActiveX Data Objects library, such as Microsoft ActiveX Data Objects 6.1 Library, and click OK.
In the affected module, explicitly declare and instantiate the object: Dim rsArtifacts As ADODB.Recordset, followed by Set rsArtifacts = New ADODB.Recordset.
In the same module, change any DAO Recordset declarations to use DAO.Recordset explicitly so they cannot be confused with ADO Recordsets.
In the VBA editor, select Debug > Compile to check whether the type error is resolved.

Work with Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for opening and editing common Microsoft Office files, making it easy to move everyday document work. It does not fix Access VBA references or replace Microsoft Access for running the database.

Frequently Asked Questions
Why does Access say ADODB.Recordset is a user-defined type that is not defined?
The project may be missing an ADO library reference. In the VBA editor, select Tools > References and enable an available Microsoft ActiveX Data Objects library.
How do I distinguish an ADO Recordset from a DAO Recordset?
Use ADODB.Recordset for an ADO object and DAO.Recordset for a DAO object in your declarations. Qualifying the types avoids ambiguity when both libraries are referenced.
Does the ADO library have to be version 6.1?
No. The available version depends on the installation. In Tools > References, select an available Microsoft ActiveX Data Objects library appropriate for the project.
How can I check whether the reference change worked?
After enabling the library and updating the declarations, select Debug > Compile in the VBA editor. Address any errors that Access identifies.




