When you use VBA as part of an Access database, or if you add in a custom component, you might end up adding a reference to the application. References are links to components or applications installed on your system that are used by the database. For instance, if your database delivers reports into an Excel spreadsheet, you’ll need to have a reference to Excel added to your application.

You can see the references that are included with a database by clicking the Tools/References menu command in the VB Editor. This shows list of all the references available on the system, with the ones that you have included at the top of the list with a check next to them. Sadly this dialog is somewhat lacking – there is very little information and the location label is often truncated so that you can’t see the name of the component that is actually being referenced.

This lack of information isn’t usually a big problem because you’ll add the reference when you’re developing the application and then never have to do anything with it. However, when running the database on a new machine or with a new version of Access or Office you might come across problems. When this happens, it’s very useful to be able to get some more information about the components that are referenced. Fortunately, you can get some more detail by running some VBA code.

There is a references collection in VB and if you iterate through this you can discover if what the references are, what they refer to and if they’re broken. There are also parameter to you a unique reference and major and minor version numbers.

Here’s a simple function to list the references in an application to the immediate (debug) window in the VB Editor.

Function ListReferences(PrintAll As Boolean) As Boolean

‘Lists the references in the current application
‘PrintAll parameter outputs all of the information about the references

Dim ref As Reference

For Each ref In Application.References

  • If ref.IsBroken Then
    • Debug.Print “Broken”
    • Debug.Print ” GUID – ” & ref.Guid
    • Debug.Print ” Major – ” & ref.Major
    • Debug.Print ” Minor – ” & ref.Minor

Else

  • Debug.Print “Name – ” & ref.Name
    • If PrintAll Then Debug.Print ” Built In – ” & ref.BuiltIn
    • If PrintAll Then Debug.Print ” Full Path – ” & ref.FullPath
    • If PrintAll Then Debug.Print ” GUID – ” & ref.Guid
    • If PrintAll Then Debug.Print ” Is Broken – ” & ref.IsBroken
    • If PrintAll Then Debug.Print ” Kind – ” & ref.Kind
    • If PrintAll Then Debug.Print ” Major – ” & ref.Major
    • If PrintAll Then Debug.Print ” Minor – ” & ref.Minor

End If
Next

ListReferences = True

End Function