UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> References    


What They Are

References are an extremely important aspect of VBA programming, regardless of the host application. References enable our projects to use object models and methods of various different libraries. In the Access VBE, click Tools -> References to see a list of references immediately available to us.

The checked references are currently referenced within the project. When a reference is checked, we will have programmatic access to all of the methods and properties that the particular reference contains. Standard references for an Access project are:

  • Visual Basic For Applications
  • Microsoft Access ##.0 Object Library
  • Microsoft DAO 3.6 Object Library

Upon highlighting a particular reference, below the list you can see the file (usually a .dll) that the library is contained in, as well as the language type.

The Visual Basic For Applications library allows to use functions such as Left() (VBA.Left) and Right() (VBA.Right), such as the Microsoft DAO 3.6 library enables us to use the DAO object model, such as a DAO.Recordset or DAO.Workspace

Why Reference Control Is Important

Reference control is exceedingly important, especially in cases where the application may be distributed to any other computer other than the one it was created on. If this reference is not available on a particular computer, then we will no longer have access to the material that our VBA code requires. This results in crashed databases that are rendered unusable until the reference issues are repaired.

It is also important to not have references that are not required. Extra references don't pose an immediate problem to the project, such as missing references, but if not tightly controlled they can be problematic as many object or methods names may be repeated from one library to the next. The more references that a project has, the more Disambiguation and Priority of references must be controlled. Often the standard references at the creation of a new VBA project are more that what is needed, and it is recommended to remove anything that is not being used.


The term Disambiguation refers to the process of explicitly telling your VBA code which reference library to pull a specific object or function from. For instance, both the DAO model and the ADO model contain a Recordset object. If you have both of these libraries referenced, which is not at all uncommon, then it is considered best practice to disambiguate their calls, like so:

  • Dim VarName As DAO.Recordset
  • Dim VarName As ADO.Recordset

As each recordset object has its own methods and properties, it would not be well to be accidentally using the ADO recordset object where you intend to use a DAO recordset, or vice-versa. Disambiguating the calls prevents this from happening.

By default, if disambiguation is not enforced on an object or method that is contained in more than one library, VBA look through the list of the references (from top to bottom - note the "Priority" buttons on the side of the References dialog) and select the first library that contains that object. For instance, if DAO 3.6 is listed before the ADO reference, a recordset call without disambiguation will be from the DAO model

Verifying References

There are a few ways of handling reference verification. At all times, reference verification should be handled to the most extent possible by the developer before deployment.

Programmatic Verification

Programmatic manipulation of references is possible through a startup procedure. Michael Kaplan explains how to do this in his link: How to guarantee that references will work in your application

Another tool for verifying and listing references can be found here: Display and List Your References

Library Locations

The VBA project will search various locations in a specified order to find library files. The list of these locations, along with much more helpful information on References, can be found in Doug Steele's link Access Reference Errors

Library File Types

Library files are generally Dynamic Link Libraries (.dll), though there are a number of other file types that can be referenced. For instance, one can create a reference to an .mdb/.mde/.accdb or .accde file and use ojects and procedures contained within that library. While these files will not automatically be listed in the References Dialog, one can click Browse, select the file type and location of the file, and create a reference to the said library

Edit Discussion
Custom Search

Thank you for your support!
This page has been accessed 20,323 times.  This page was last modified 00:20, 28 September 2012 by Mark Davis. Contributions by Jack Leach and gregjgrose  Disclaimers