Microsoft Access
Access and the missing reference: how to fix it
A new computer, an Office update, and the database that worked yesterday now throws errors on simple functions? A missing reference is often to blame.
In short
- An Access database with VBA code uses libraries: outside components that must exist on every computer.
- If one is missing on a computer, Access marks it as MISSING, and even functions that have nothing to do with that library can break.
- The check is made in the References dialog box of the Visual Basic Editor, with the full version of Access.
- Clear the check box of the missing library or show Access where it is, then compile the database.
- The most common causes: components not installed, different versions of Office, 32-bit controls on 64-bit Office.
The symptoms
The problem almost always appears after a change: a new computer, an Office update, the database copied to a colleague. The most common signs, with the messages from the English version of Access:
- “Compile error: Can't find project or library”: Access cannot find a project or library that the code uses.
- A warning when the database opens that it contains a missing or broken reference to a file, which must be fixed for the database to work.
- Errors on common functions, for example date and text functions, in forms and queries that used to work.
The third case confuses many people: Microsoft explains that a missing reference can break even functions that have nothing to do with that library, and that the code will not run until every missing reference is resolved.
What references are
Besides Access itself, the VBA code in a database uses libraries: for example the Excel library to export a sheet, the Outlook library to prepare an email, or a control to show a calendar. The list of these libraries is known as the references, and it is saved in the database.
The library file, however, is not in the database: it is on the computer. Microsoft warns that when only the database is copied to another computer, you need to make sure every file on the list exists there too, in the right version.
- 1The databasewith the list of references
- 2The computermust have every library
- 3Library not foundmarked as MISSING
- 4The fixremove or find the library
How to find the missing reference
Open the Visual Basic Editor
With the full version of Access, open the database and press Alt+F11, or choose Database Tools › Visual Basic.
Open the references
In the editor, choose Tools › References. The list of libraries used by the database appears, each with a check mark.
Look for the word MISSING
The missing library has “MISSING:” in front of its name. Note down the full name: it tells you what is missing from the computer.
With the free Access Runtime, references can be neither viewed nor changed: the fix is made on a computer with full Access. We cover it in the guide to the Access Runtime.
How to fix it
First of all, make a copy of the database. Then, depending on whether the library is needed or not:
If the library is no longer needed
Clear the check box next to the MISSING entry and close the dialog box. This often happens with libraries added years ago and never used.
If the library is needed
If you know where the file is, point to it with the Browse button. If it is missing from the computer, the program or component that contains it has to be installed.
Compile the database
From the Debug menu, choose the Compile command. Microsoft advises always doing this after changing references: if compiling stops, there are other references to fix.
Test on a clean computer
Microsoft advises testing the database on a computer with the oldest version of Office you need to support, before distributing it.
A developer can make the database less fragile with late binding to the Office libraries: the database looks for the library only when it needs it, with no fixed reference. Microsoft gives it as a way to work around problems between different versions, although in general it prefers fixed references.
Would you like an opinion on your case?
Send us the file: within 48 hours you receive a free written assessment, even if the answer is that a small fix is enough.
The most common causes
- A component that is not installed: Microsoft notes that the file often exists on the computer of whoever developed the database, but not on the one where it is used.
- A component not registered properly in Windows, even though the file is there: it has to be registered again, a job for a technician.
- 32-bit ActiveX controls on 64-bit Office: the Windows Common Controls, such as the tree view or the date picker, do not load. We explain this in the guide to Access 32-bit or 64-bit.
- A library file that has been moved or renamed: Access looks for it where it used to be; if its name has changed, the old reference must be removed and the new one added.
How to stop it happening again
Every extra library is one more point where the database can break on the next new computer. Fewer references, the same version of Office on every computer and a test before every update greatly reduce the surprises.
If the database depends on components that nobody knows how to install any more, the lasting solution is to move it to a platform that does not depend on what is on each computer. Here is how we turn Access databases into web applications.
Frequently asked questions
Can a missing reference break unrelated functions?
Yes: Microsoft explains that with a missing reference even common functions, such as date and text functions, can stop working. Once the reference is fixed, they work again.
Can it be fixed with the Access Runtime?
No: with the runtime, references can be neither seen nor changed. A computer with the full version of Access is needed; the corrected database is then distributed to the others.
Is it risky to clear the check box of a library?
If the code uses it, compiling stops and says so: that is how you find out. Do it on a copy of the database and tick the box again if needed.
Why does it work on the computer of whoever created it but not on the others?
Because that computer has libraries and components installed over the years that the others lack. That is why Microsoft advises testing the database on a clean computer.
Does it have to be fixed on every computer?
If the problem is in the database, fixing it once and distributing the file is enough. If a component is missing on one computer, it has to be installed on that computer.
Sources
- Microsoft: error when compiling a module in Access
- Microsoft: VBA functions that break with missing references
- Microsoft: resolve reference issues in an Access database
- Microsoft: can't find project or library
Official Microsoft pages.