Fix Access “User-Defined Type Not Defined” Error for Dim Statements
Question details
The user is encountering a VBA compilation error when declaring a variable for a custom class module that cannot be found.

- 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.
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.
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.
Open your database in Microsoft Access and press ALT + F11 to launch the Visual Basic for Applications (VBA) Editor.
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.
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.

Remove Custom Code and Use the Built-in SysCmd Indicator
If you cannot find the custom class module, you can safely comment out the failing code and use Access's native SysCmd method to display a progress bar instead.
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. Download the Installer: Visit the official WPS Office website and click the 'Free Download' button.
- 2. Install the Suite: Run the downloaded installer file and follow the simple on-screen instructions to complete the setup.
- 3. Start Creating: Launch WPS Office and immediately start opening, editing, or creating your documents, spreadsheets, and presentations.

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.




