VBA & Macro Problems

How to Fix "User-Defined Type Not Defined" for ADODB in Access

Khadija KhanKhadija Khan Oct 23, 2026 868 views

Question details

The user is encountering a VBA compile error when attempting to use ADODB objects because the required library reference is missing from the project.

How to Fix "User-Defined Type Not Defined" for ADODB in Access
Product
Microsoft Access
Device & OS
not provided
Scenario
Writing, compiling, or running VBA code in Microsoft Access that initiates database connections using ADODB.
Observed behavior
The VBA editor halts execution, throws a "User-defined type not defined" error, and highlights the ADODB variable declaration.
Before you start

Verify whether your VBA project is designed to connect to an external SQL database (which requires ADO) or local Access tables (where the default DAO library is recommended).

Solution 1Recommended

Enable the Microsoft ActiveX Data Objects Library

Add the missing ADO reference in the VBA editor to resolve the compile error and allow ADODB objects to function.

Microsoft Access does not include the ADO library by default in newer versions, opting for DAO instead. You must manually activate it in the VBA References menu.

1
Open the VBA Editor

Press Alt + F11 while inside Microsoft Access to open the Visual Basic for Applications (VBA) editor.

2
Access the References Menu

In the top menu bar, click on "Tools" and select "References" from the dropdown menu.

3
Select the ADO Library

Scroll down the alphabetical list of available references and check the box next to "Microsoft ActiveX Data Objects 6.1 Library" (or the highest version available on your system).

4
Compile the Project

Click "OK" to apply the changes, then navigate to "Debug" > "Compile [Project Name]" to ensure the error is completely resolved.

Enable the Microsoft ActiveX Data Objects Library
Version Compatibility: If version 6.1 is not available in your list, checking older versions like 2.8 will also work perfectly for most standard ADODB.Connection requirements.
Free Microsoft Office alternative

Need a Free Alternative to Microsoft Office? Try WPS Office

If you frequently encounter complex VBA errors in Microsoft Office, you might appreciate a lighter, highly compatible alternative. WPS Office offers a powerful suite with native macro support, a familiar interface, and seamless performance—completely free.

  1. 1. Download the Installer: Visit the official WPS Office website and click the free download button for your operating system.
  2. 2. Install WPS Office: Run the downloaded setup file and follow the quick on-screen instructions to complete the installation.
  3. 3. Open Your Files: Double-click any of your existing Office documents or macro-enabled spreadsheets to open them directly in WPS Office.
Fully compatible with Microsoft Excel (.xlsx, .xlsm), Word, and PowerPoint file formats.Robust built-in VBA and macro support in WPS Spreadsheet to run your automated tasks.Free, lightweight design that installs quickly and consumes minimal system resources.Familiar tabbed user interface makes migrating from Microsoft Office completely seamless.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Microsoft Access use DAO instead of ADO by default?

DAO (Data Access Objects) is optimized specifically for the Access database engine (Jet/ACE). It natively understands Access-specific features, such as multivalue fields and complex query designs, making it faster and more reliable for local database tasks.

What is the primary difference between ADO and DAO in VBA?

DAO is designed primarily for querying and managing local Access databases. ADO (ActiveX Data Objects) is a broader technology better suited for connecting to external data sources, such as SQL Server or web databases.

Can I use both DAO and ADO in the same Access database?

Yes, you can check both library references in the VBA editor. However, you must explicitly declare your objects (for example, using 'Dim rs As DAO.Recordset' or 'Dim rs As ADODB.Recordset') to prevent ambiguous reference errors in your code.