Microsoft KB Archive/286300

= How Access 2002 resolves Visual Basic for Applications references =

Article ID: 286300

Article Last Modified on 8/15/2005

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition
 * Microsoft Visual Basic for Applications 1.0

-



This article was previously published under Q286300





For a Microsoft Access 97 version of this article, see 280465.

For a Microsoft Access 2000 version of this article, see 248941.

Advanced: Requires expert coding, interoperability, and multiuser skills.

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



SUMMARY
This article explains the steps that Microsoft Access takes to resolve Visual Basic for Applications (VBA) references.



MORE INFORMATION
To view the current references, start the Visual Basic Editor (press ALT+F11), and click References on the Tools menu.

The pertinent file, for example, a type library, object library, or control library, for each reference is loaded according to the information displayed in the References box. However, if the file is not found, Access takes the following steps to determine the file's location.

For each reference that is selected, Access does the following:  Access checks to see if the referenced file name is currently loaded.  If not, Access verifies whether the RefLibPaths registry key exists. If so, Access looks for a named value with the same name as the reference. If there is a match, Access loads the reference from the path pointed to by the named value.

You can add this key to the registry and then add the names and locations of any add-ins or libraries as string values beneath that key. Create the RefLibPaths key at the following location:

HKEY_LOCAL_MACHINE\Software\Microsoft\Office\10.0\Access

Within the key, add a string value that specifies the name and location of the file to which the reference is set. The name should be the file name, including the extension, and the location should be the path plus the file name. For example, if you have set a reference to the Northwind sample database, you can add the following values: Name: Northwind.mdb Data: C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb NOTE: You do not need this key if the file that you want to reference is located in any of the directories that are mentioned in the table below.  If the RefLibPaths registry key does not exist or does not contain a proper reference, Access next uses the SearchPath API to search for the referenced file. The following searches are performed:



If the reference is not found, you may receive the following error message when you compile the project or try to run a procedure:

Your Microsoft Access database or project contains a missing or broken reference to the file ' ' version x.x;.


 * To ensure that your database or project works properly, you must fix this reference.


 * To learn how to fix this reference, click Help.

The error message appears only once for each broken reference while the database is open. For example, if you open MyDatabase.mdb and it is missing a reference to the Microsoft Calendar Control and the Microsoft DAO library, you receive two error messages, one for each missing reference. You do not receive the error message again, unless you do not fix the reference, and then close and reopen the database. If you fix the references and then save the database, you do not receive the error messages the next time you open the database.

BrokenReference Property
The Application object for Access has a BrokenReference property that tells you whether or not any references are broken. To check this property, follow these steps:  Press CTRL+G to open the Immediate window.</li> In the Immediate window, type the following:

?Application.BrokenReference

</li> Press ENTER.

Note that the property returns True if there are missing references and False if not.</li></ol>

NOTE: In an Access run-time application, you cannot view references from a menu. However, the following article demonstrates how to view references by using code:

209849 How to loop through the references to view their properties in Access 2000

<div class="references_section">