How to Fix Access #Type Error After Converting MDB to ACCDB
Question details
The user encounters a #Type error in a VBA function designed to concatenate email addresses from a recordset after migrating a database format.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Upgrading an Access database from the older MDB format to the newer ACCDB format and running existing VBA scripts.
- Observed behavior
- A VBA function that reads and concatenates email addresses returns a #Type error instead of the expected email string.
Ensure you have a secure backup of your original MDB file and the newly converted ACCDB database before modifying your VBA code. Also, verify that the email fields in your table do not contain any Null values, as these can disrupt string operations.
Update VBA Declarations and Syntax for ACCDB Compatibility
Modify your VBA code to use explicit DAO declarations and the correct string concatenation operator to resolve the #Type error.
When upgrading from MDB to ACCDB, the default library references can change. Ambiguous object declarations might cause Access to default to ADO instead of DAO, triggering type mismatch errors. Using explicit references and strict string operators ensures compatibility.
Open your database in Microsoft Access and press 'Alt + F11' on your keyboard to launch the VBA Editor.
Locate the function causing the #Type error. Change generic declarations to explicit DAO types. For example, change 'Dim db As Database, r As Recordset' to 'Dim db As DAO.Database, r As DAO.Recordset'.
Ensure your iteration or result variable is declared explicitly as a String rather than a Variant (e.g., 'Dim it As String').
Modify the recordset opening statement to explicitly define it as a dynaset by updating the line to: 'Set r = db.OpenRecordset(sql, dbOpenDynaset)'.
Replace the arithmetic '+' operator with the VBA string concatenation '&' operator. Change your loop statement from 'it = it + r!email + ","' to 'it = it & r!email & ";"'. Note that a semicolon is the standard separator for email clients.

Looking for a Lightweight Alternative to Microsoft Office?
While Microsoft Access is used for complex database management, many users find the complete Microsoft Office suite heavy and expensive. WPS Office provides a free, lightweight, and highly compatible alternative for your daily word processing, spreadsheet, and presentation needs.
- 1. Download the Installer: Visit the official WPS Office website and click the download button to get the free installation package.
- 2. Install WPS Office: Run the downloaded installer and follow the simple on-screen instructions to set up the software on your computer.
- 3. Open Existing Documents: Launch WPS Office and easily open or drag-and-drop your existing Word, Excel, and PowerPoint files to continue working seamlessly.

Frequently Asked Questions
Why does upgrading from MDB to ACCDB cause VBA #Type errors?
The ACCDB format handles library references differently than the older MDB format. If your VBA code uses generic declarations like 'Recordset', Access might default to the ADO library instead of DAO, causing a type mismatch error.
Why should I use '&' instead of '+' for string concatenation in VBA?
While '+' can sometimes concatenate strings, it is fundamentally an arithmetic operator and can cause unexpected math operations or errors if numbers or Null values are present. The '&' operator strictly enforces string concatenation.
How do Null values affect my VBA string concatenation?
If a field contains a Null value and you use the '+' operator, the entire concatenated result becomes Null. Using the '&' operator handles Nulls gracefully by treating them as empty strings.
What is the standard separator for multiple email addresses?
In most email clients, including Microsoft Outlook, the semicolon (;) is the standard separator used to distinguish between multiple email recipients.




