Others

Fix Access “User-Defined Type Not Defined” Error for Dim Statements

Amos GikundaAmos Gikunda Oct 15, 2026 869 views

Question details

The user is encountering a VBA compilation error when declaring a variable for a custom class module that cannot be found.

How to Fix Access “User-Defined Type Not Defined” Error for a Dim Statement
Product
Microsoft Access 2016
Device & OS
not provided
Scenario
Running or compiling VBA code that includes a custom progress bar class (such as clsRidesPBar) or a Dim statement referencing an unavailable type.
Observed behavior
Microsoft Access reports a 'User-defined type not defined' error, preventing the macro or database function from executing.
Before you start

Ensure you have access to the VBA Editor (ALT + F11) in Microsoft Access and verify if any custom class modules have been accidentally deleted or excluded during a recent database migration.

Solution 1Recommended

Restore or Import the Missing Class Module

This error most commonly occurs because VBA cannot find the specific class module referenced in your Dim statement. Importing the missing file resolves the definition error.

If you are using custom objects like clsRidesPBar, the database must physically contain the class module for the code to compile successfully.

1
Open the VBA Editor

Open your database in Microsoft Access and press ALT + F11 to launch the Visual Basic for Applications (VBA) Editor.

2
Check the Project Explorer

Look at the 'Project Explorer' pane on the left side to see if the required class (e.g., clsRidesPBar) is listed under the 'Class Modules' folder.

3
Import the Class File

If the module is missing, right-click anywhere in the Project Explorer, select 'Import File', and browse for the missing .cls file from a backup or source location to import it.

Restore or Import the Missing Class Module
Free Microsoft Office alternative

Switch to WPS Office for Lightweight, Free Productivity

While Microsoft Access handles highly specialized databases, your primary daily document, spreadsheet, and presentation tasks can be completed much faster and more cost-effectively with WPS Office. Enjoy a comprehensive, familiar suite without the heavy subscription fees.

  1. 1. Download the Installer: Visit the official WPS Office website and click the 'Free Download' button.
  2. 2. Install the Suite: Run the downloaded installer file and follow the simple on-screen instructions to complete the setup.
  3. 3. Start Creating: Launch WPS Office and immediately start opening, editing, or creating your documents, spreadsheets, and presentations.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats.Lightweight architecture that runs smoothly on older devices and multiple OS platforms.Familiar, tabbed user interface that requires zero learning curve for Office users.Includes a powerful built-in PDF editor and format converter for free.
microsoft office alternative - wps office

Frequently Asked Questions

What exactly does 'User-defined type not defined' mean in VBA?

This compile-time error means VBA encountered a variable declaration (a Dim statement) for an object, class, or custom data type that does not exist in the current project or its referenced external libraries.

How do I check for missing references in Access VBA?

Open the VBA Editor by pressing ALT + F11, click 'Tools' in the top menu bar, and select 'References'. Look through the list for any checked items labeled with 'MISSING:'. You must uncheck these or browse to locate the correct library file.

Why do I get a syntax error when assigning SysCmd to a variable?

When using SysCmd to initialize or manipulate the Access progress meter, it acts as a method rather than a function. Therefore, you must call it directly without parentheses and without trying to assign a return value to a variable.