Pacific Database

Home | Contact | FAQs | View Cart

A world of information at your fingertips

How do I add a reference to an Access project?

In order to use certain external facilities, such as Excel functions or functionality provided by third-party controls, and so on, you must add a reference to their type libraries in the Access project.

  1. The first thing you need to do is open the References dialog. To do that, open any code module (by pressing Alt+F11), and select References from the Tools menu. The References dialog is displayed.
     
  2. The next thing you need to do is to locate the library you want to use. Do this by simply scrolling through the list and ticking the one you want.

  1. In the event you don't see the library you want, you can add it manually by clicking Browse. The Add Reference dialog is displayed.

  1. Once you find the desired library, select it and click Open. The library is added to the list in the References dialog, but it is NOT ticked.
     
  2. Locate the newly added reference and tick it. Finding the library may not always be as easy as you would think, because the library may not be named logically.

  1. Once you've located and ticked the library you want to use, you can then assign it's order of precedence. Unfortunately, because the new library isn't moved to the top of the lists where all the other selected libraries are displayed, you will have to close the References dialog, and re-open it.
     
  2. Click OK to save your changes.

It is important to note that when looking for a library function, Access employs an order of precedence. For example, if you simply declare the following object variable:

Dim rs As Recordset

...and you have both the ADOX and DAO libraries referenced, Access will attempt to use the first recordset object it comes to, regardless of what you had intended. To ensure that Access uses the correct library, move the library's reference to the higher position in the list using the up & down arrows. In the above example, Access will attempt to use the DAO 3.6 library before it attempts to use the ADOX library. Of course, the best approach is to disambiguate your code, like so:

Dim rsD As DAO.Recordset
Dim rsA As ADODB.Recordset

...so there is no confusion. In most cases, however, there is little need to change the order of precedence.