ACCESS: How to Reference Classes That Exist in Multiple Libraries

Support for Office 2003 has ended

Microsoft ended support for Office 2003 on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

This article has been archived. It is offered "as is" and will no longer be updated.
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb and .accdb) and to a Microsoft Access project (.adp).

If your Microsoft Access database contains a reference to multiple librarydatabases, type libraries, or object libraries, it is possible for the sameclass name to exist in more than one referenced file. If you want todeclare a variable of that type, you must explicitly state which referencecontains the class that you want to use. This article shows you how tospecify a particular reference file in code.
More information
Suppose that your Microsoft Access database contains two references: onereference to a library database called MyDatabase, which contains a classcalled RecordSet, and another reference to Microsoft DAO 3.6 ObjectLibrary, which also contains a class called RecordSet. To dimension a variable of type RecordSet from the MyDatabase reference, you must use the following syntax:
Dim rs as MyDatabase.RecordSet				
If you do not explicitly declare the reference name when you dimension thevariable, whichever reference appears first in the References dialogbox is automatically assumed. If the wrong reference is assumed, you mayencounter error messages when you try to use the properties and methods ofthe declared object.

You can use the Microsoft Access Object Browser to determine the referencename. To use the Object Browser, open any module in Design view, and thenclick Object Browser on the View menu (or press the F2 key). The name that appears in the Project/Library box of the Object Browser is the name of that reference.
For more information about setting references, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type references command (tools menu) in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about using the Object Browser, click Microsoft Access Help on the Help menu, type work with objects in visual basic by using the object browser in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.
type mismatch ACC2000 ACC2002 ACC2003 ACC2007 ACC2010

Article ID: 209912 - Last Review: 01/17/2015 13:58:45 - Revision: 3.0

Microsoft Access 2000 Standard Edition, Microsoft Access 2002 Standard Edition, Microsoft Office Access 2003, Microsoft Office Access 2007, Microsoft Access 2010

  • kbnosurvey kbarchive kbcode kbhowto kbinfo KB209912