How Access resolves Visual Basic for Applications references (824255)
The information in this article applies to:
- Microsoft Office Access 2003
- Microsoft Access 2002
- Microsoft Access 2000
- Microsoft Access 97
This
article applies to a Microsoft Access database (.mdb) and to a Microsoft Access
project (.adp). Advanced: Requires expert coding,
interoperability, and multiuser skills.
Important This article contains information about how to modify the registry. Make sure to back up the registry before you modify it. Make sure that you know how to restore the registry if a problem occurs. For more information about how to back up, restore, and modify the registry, click the following article number to view the article in the Microsoft Knowledge Base: 256986 Description of the Microsoft Windows registry SUMMARYThis article discusses the sequence of tasks that Microsoft
Office Access 2003, Microsoft Access 2002, Access 2000, or Access 97 performs to resolve the references in Microsoft Visual Basic
for Applications (VBA). MORE INFORMATIONWarning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall your operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk. In Access, you can view the VBA references
that are currently selected by using the Visual Basic Editor. To do this,
follow these steps:
- Start Access.
- Open an Access database.
- Press ALT+F11 to open the Visual Basic Editor.
- In the Visual Basic Editor window, click
References on the Tools menu.
In the
References dialog box, you can see the references that are
selected. Note When you select a reference, you can also view the information
that corresponds to the file that must be loaded to use the
reference. The pertinent file may be a type library, an object
library, or a control library. The pertinent file for each reference is loaded
according to the information that appears in the References
dialog box. However, if the file is not found, Access searches for the
file in different locations on your computer. For each VBA reference
that is selected, Access performs the following tasks:
- Access verifies whether the referenced file is already
loaded.
- Access verifies whether the
RefLibPaths registry key
exists if the referenced file is currently not loaded.
If the
RefLibPaths registry key
exists, Access searches for a named value that has the same name as the
reference. If there is a match, Access loads the reference from the path that
is mentioned in the named value.
Note You can manually add the RefLibPaths registry key to the
registry and, then you can add the names and the locations of any add-ins or of
any libraries that are under the RefLibPaths registry key. To do this,
follow these steps:
- Click Start, and then click
Run.
- In the Open box, type
regedit, and then click OK.
- In the Registry Editor window, locate the following
registry key:
Access 2003: HKEY_LOCAL_MACHINE\Software\Microsoft\Office\11.0\Access Access 2002: HKEY_LOCAL_MACHINE\Software\Microsoft\Office\10.0\Access Access 2000: HKEY_LOCAL_MACHINE\Software\Microsoft\Office\9.0\Access Access 97: HKEY_LOCAL_MACHINE\Software\Microsoft\Office\8.0\Access - Right-click the Access registry key,
point to New, and then click Key.
- Name the newly created key
RefLibPaths.
- Click RefLibPaths.
- Right-click anywhere in the right pane, and then click
String value.
- Name the newly created String value by using the same
name as the VBA reference.
- Right-click the String value that you created in step
8, and then click Modify.
- In the Edit String dialog box, type
the location of the file that must be loaded to correspond to the reference in
VBA.
The registry value name must be the file name plus the extension.
The location (value data) must be the path plus the file name. For example, if
you set a reference to the Northwind sample database, you can add the following
values:
- Value Name: Northwind.mdb
- Value Data: C:\Program Files\Microsoft
Office\Office11\Samples\Northwind.mdb
- Repeat step 7 through step 10 to add the names and to
add the locations of the appropriate add-ins or of the appropriate libraries as
String values.
- On the File menu, click
Exit.
- Access uses the SearchPath API to search
for the referenced file if the RefLibPaths registry key does not exist
or does not contain a correct reference. 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 folder and the
System32 folder that are located in the Windows folder or in the WINNT folder.
| WinDir | The folder where the operating system
files run. This is typically the Windows folder or the WINNT folder. | PATH Environment Variable | This system variable
contains a list of folders that are directly accessible by the
system.
Microsoft Windows NT 4.0: In Control Panel, double-click
System, and then click the Environment tab.
The PATH variable is in the System Variables list.
Microsoft Windows 2000, Microsoft Windows XP, and Microsoft Windows Server 2003: In Control
Panel, double-click System, click the
Advanced tab, and then click Environment
Variables. The PATH is in the System Variables list.
| File Directory | The folder that contains the .mdb
file, the .mde file, the .adp file, or the .ade file, and any subfolders. |
Note Access does not require the
RefLibPaths registry key
if the file that you want to reference is located in any of the directories
that are mentioned in the table. If Access cannot find the
reference, you receive the following error message when you compile the project
or when you try to run a procedure: Your
Microsoft Office Access database or project contains a missing or broken
reference to the file file name.
* To
ensure that your database or project works properly, you must fix this
reference. Note While the database is open, you receive the previous error
message one time for each broken reference. For example, if you open
MyDatabase.mdb and MyDatabase.mdb is missing a reference to the Microsoft
Calendar Control and to the Microsoft DAO library, you receive two error
messages, one for each missing reference. You do not receive the error messages
again unless you do not fix the references, you close the database, and then
you reopen the database. If you fix the references and then you save the
database, you do not receive the error messages the next time that you open the
database. The BrokenReference property
The Application object for Access has a BrokenReference property that tells you if any references are broken. To check
the BrokenReference property, follow these steps:
- Start Access.
- Open an Access database.
- Press ALT+F11 to open the Visual Basic Editor.
- Press CTRL+G to open the Immediate window.
- In the Immediate window, type the following command, and
then press ENTER:
?Application.BrokenReference
Notice that the BrokenReference property for the Application object returns True if there are missing references. Otherwise,
the BrokenReference property returns False.
REFERENCES
For more information about references, click Microsoft Visual
Basic Help on the Help menu, type References Collection in the Search for box in the Assistance pane, and then click Start searching to view the topic.
For more 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
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbPubTypeKC KbVBA kbProgramming kbinfo kbRegistry kberrmsg KB824255 kbAudDeveloper |
---|
|