Access error reference
“Can't find project or library”: fixing a MISSING reference in Access VBA
The error often highlights an innocent built-in function — `Left`, `Date`, `Format`. The real cause is a reference in the VBA project that points to a library that is not on this PC.
The message
Compile error: Can't find project or library
On a French Access: « Projet ou bibliothèque introuvable ». In the VBA editor's Tools > References, the culprit is labelled “MISSING:”.
Where it shows up
When compiling, or when the first form whose code uses any function opens: a single missing reference stops VBA from resolving other names, hence built-in functions that suddenly “can't be found”.
Common causes
- a component installed on the author's PC but not yours: ActiveX control, third-party library, an older version of an Office library;
- a library that only exists in 32-bit, on 64-bit Office (for example the old DAO 3.6 library, some ActiveX controls);
- a component Office no longer ships: the Calendar control (removed since Access 2010), Office Web Components;
- a moved or renamed file (another Access database referenced as a library).
How to reproduce and check it
- Open the VBA editor (Alt+F11), then Tools > References: the ticked line marked “MISSING:” is the cause.
- Note the name and path shown at the bottom of the dialog: they tell you which file is missing.
- From code,
For Each r In Application.References : If r.IsBroken Then Debug.Print r.Name, r.FullPathlists broken references.
How to fix it
Untick the missing reference. If the code needs it, tick the version installed on the PC (for DAO 3.6: “Microsoft Office … Access database engine Object Library”), or switch that code to late binding (CreateObject) so it no longer depends on a specific version. Then compile (Debug > Compile) to check nothing is left.
What Auscult reports
The diagnostic reads the project's references and knows which are broken. It separates three cases: a library missing on the analysis PC but probably present on yours (reported separately; the object is not judged without it); a library that only exists in 32-bit, broken for every 64-bit Office user (“fails on 64-bit Office”); and components Office no longer ships, flagged for removal.
Measured on our test corpus: this message was recorded while analysing 12 of 965 applications.