Others

How to Fix Access #Type Error After Converting MDB to ACCDB

Khadija KhanKhadija Khan Oct 28, 2026 868 views

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.

How to Fix Access #Type Error After Converting MDB to ACCDB
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Open your database in Microsoft Access and press 'Alt + F11' on your keyboard to launch the VBA Editor.

2
Make DAO Declarations Explicit

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'.

3
Declare the Result Variable as String

Ensure your iteration or result variable is declared explicitly as a String rather than a Variant (e.g., 'Dim it As String').

4
Open Recordset as a Dynaset

Modify the recordset opening statement to explicitly define it as a dynaset by updating the line to: 'Set r = db.OpenRecordset(sql, dbOpenDynaset)'.

5
Use the Correct Concatenation Operator

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.

Update VBA Declarations and Syntax for ACCDB Compatibility
Syntax Corrected: Using explicit DAO references prevents ambiguity between DAO and ADO libraries, effectively eliminating the type mismatch error in newer Access formats.
Free Microsoft Office alternative

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. 1. Download the Installer: Visit the official WPS Office website and click the download button to get the free installation package.
  2. 2. Install WPS Office: Run the downloaded installer and follow the simple on-screen instructions to set up the software on your computer.
  3. 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.
Fully compatible with Microsoft Office formats including .docx, .xlsx, and .pptx.Lightweight installation with a familiar, easy-to-use tabbed user interface.Built-in PDF editing tools and advanced spreadsheet functions.Free to download and use with seamless cloud sync capabilities.
microsoft office alternative - wps office

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.