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:
Search area Description Application Directory Location of Msaccess.exe. Current Directory Directory that you see if you click Open on the File menu. System Directory The System and System32 folders, located in the Windows or Winnt folder. WinDir Folder where the operating system files are running. This is usually the Windows or Winnt folder. PATH environment variable This system variable contains a list of folders directly accessible by the system.
In Microsoft Windows 98: The PATH statement is located in the Autoexec.bat file.
In Microsoft Windows NT: In Control Panel, open the System tool, and click the Environment tab. The path is in the System Variables list.
In Microsoft Windows 2000: In Control Panel, open the System tool, and on the Advanced tab, click Environment Variables. The path is in the System Variables list.File Directory Folder that contains the .mdb, .mde, .adp, or .ade file, and any subfolders.
If the reference is not found, you may receive the following error message when you compile the project or try to run a procedure:
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.
- In the Immediate window, type the following:
?Application.BrokenReference
- Press ENTER.
Note that the property returns True if there are missing references and False if not.
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
REFERENCES
For more information about references, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type References Collection in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
For additional information about missing references, click the following article number to view the article in the Microsoft Knowledge Base:
283806 Visual Basic for Applications (VBA) functions break in a database with missing references
Additional query words: pra type libraries compile error can t find project or library inf
Keywords: kbprogramming kbhowto KB286300