How Microsoft Access Resolves VBA References

When Access needs to use the file you've referenced, it does so in the following sequence:

1. It checks the location indicated in the References dialog box.

2. It checks to see if the file is already loaded.

3. It checks the RefLibPaths Registry key for a value in the name of the referenced file.

4. If the RefLibPaths key does not exist, or doesn't contain the required value, Access checks the Search Path in the following order:

a. Application folder (where msaccess.exe is located)

b. Current folder

C. System folder (System and System32 folders, located in the Windows or WinNT folder)

d. WinDir system variable (the folder where the operating system is running, usually the Windows folder)

e. PATH environment variable (contains a list of folders accessible by the system)

f. File folder (the folder that contains the ACCDB, ACCDE, MDB, MDE, ADP, or ADE file, and any subfolders

If Access still can't find the referenced file, it generates an error. When you check the References dialog box, you may see a reference marked MISSING, as shown in Figure 14-5.

References - Access 2007 Book

0 Visual Basic For Applications *

Vl Microsoft Access 2007 Object Library rni

0 OLE Automation

Microsoft Office 2007 Access database engine Objec

Figure 14-5

Although Access warns you about broken references when you display the VBA Editor, the following property returns True if a reference is broken, and False otherwise. Run this code in the Immediate window to test:


You can also use the isBroken property of a Reference object to determine if a specific reference is broken. This property, issued in the Immediate window, returns True if the reference to DAO is broken, and False otherwise:


Appendix B fully explains creating and managing references.

Once a library is linked, you can use its functions as easily as you would a built-in Access function. For example, after linking Excel, the following code demonstrates how to access Excel's lnchesToPoints() function, which, as you would expect, converts inches to points:

Public Sub Linking2Excel()

Debug.Print Excel.Application.InchesToPoints(l) End Sub

Was this article helpful?

0 0


  • Henry
    How Access Resolves Visual Basic for Applications References?
    9 years ago

Post a comment