Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Bugs: Access 2000: Type Mismatch or User Defined Type Not Defined

Author(s)
Dev Ashish
  When you create a new database in Access 2000, the default data access library used is ADO.  That is, ADO will be selected under Tools/References in VBE instead of DAO. Converted databases still retain DAO as the default library and ADO will not be selected under References.

The "Type Mismatch" error occurs as the global class Recordset is evaluated as ADODB.Recordset instead of the DAO.Recordset, while the "User Defined Type Not Defined" error is generated at compile time because there is no Database object in ADO.

To fix this problem, uncheck the ADO reference and check DAO 3.6 Library as a new reference.

You may still receive this error message when referring to DAO Recordsets if you have both ADO and DAO selected under References.  This is because the ADO reference is listed above DAO in the References dialog and hence, is taking precedence at runtime when Access tries to resolve your data types.  To move the DAO reference above the ADO one in the dialog,

  • Uncheck the ADO reference.
  • Close the References dialog.
  • Open the dialog again.
  • Check the ADO reference.
  • Close the dialog.

If you are working with a database in which both ADO and DAO references are selected,   the best way is to always fully qualify your data types.  For example:

Dim rsCustomers as ADODB.Recordset
Dim rsInvoices as DAO.Recordset

For more details on which references to use in your application, view this article.

Article ID: 197110
ACC2000: References to Set When Working with Microsoft Access

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer