While using the VBA code or macros in Microsoft Access, if you are receiving an error message “Compile error: Can’t find project or library” then it is likely due to a reference object or library type missing. Sometimes, this error is also caused because of a missing link between a library & program code. Fortunately, the issue can be easily fixed by adding/removing the reference to library and registering the library file.
Libraries are the component that provides functionality. Access and its programming language (VBA) are two essential libraries in every project. If MS Access doesn’t provide something which you are looking for, then you can find a library and add it.
But sometimes adding extra libraries causes numerous errors and issues. One such error is “Compile error: Can’t find project or library” (the interface of the error is shown below).
Thus, if you too getting the same error in your MS Access Database, then apply the resolutions mentioned below in this post and solve this error on your own.
Before proceeding further, let’s take a look at one of the real user examples who is facing the same issue.
I believe my Access 365 had an update now when I try to open my Database if receive this error:
Compile error: Can’t find project or library
and this sentence is highlighted in the code: Private Function HandleButtonClick(intBtn As Integer)
Dim dbs As Database. Any idea what I need to do?
Source: Microsoft Community
How Do I Find A Missing Library/Reference In VBA?
Access loads the relevant file (such as a type library, an object library, or a control library) for each reference, as per the information shown in the References box. If Access is unable to fetch this file, then it will perform the following procedures to search for the file.
- Access checks for the referenced file whether it is currently loaded in memory or not.
- If the file is not loaded there, then MS Access tries to verify that RefLibPaths registry key exists there or not. But, if it is present there then Access checks for a named value which is having the same name as that of the reference. If it matches well, Access loads the reference from the path that the named value points to.
- After this the Access makes searches for the referenced file in the following location and in this order:
- The Application folder (the location of the Msaccess.exe file).
- The current folder that you see if you click Open on the File
- The Windows or Winnt folder where the operating system files are running.
- The System folder is under the Windows or Winnt folder.
- The folders in the PATH environment variable that is directly accessible by the operating system.
4. If access won’t get such a file then a reference error occurs.
Lists of Reference Error Messages
Following here is the list of some reference error message that Access users frequently encounters.
- “Can’t find project or library”
- “Method MethodName of Object ObjectName Failed”
- “Function is not available in Usage expression”
- “Variable not defined” or “User-defined type not defined”
- “Invalid procedure call or argument,”
- “ActiveX component can’t create object”
Reason Behind The Access Can’t Find Project Or Library Error
Since the Access database can’t find project or library occurs while running the VBA code or macros in Access so, we cannot blame a single reason behind this.
There could be several factors that can trigger this error, they are as follows:
- When a reference object or library type goes missing then they aren’t found by a program which leads to this error.
- In case, a library is toggled ON or toggled OFF, it can lead to a missing link between a library & the program code. Hence, the compile error is generated.
Solution To Fix “Compile Error: Can’t Find Project or Library” Error
Below here is the following manual method to resolve VBA can’t find project or library error.
Method 1: Adding Or Removing A Reference To A Library
As mentioned above, this error is mainly caused due to reference object or library type missing when using the macros & VBA functions.
Thus, you can easily solve this issue by following the below steps:
- Launch the MS Access Database application.
- Then, you have to open a module in the design view. Instead, you can press the ALT + F11 keys together to switch to Visual Basic Editor.
- After that, click on Tools menu >> click on References.
- Here, uncheck a checkbox “Missing: Microsoft Access Object” >> click on “Ok” option to save the changes you have made.
Method 2: Registering a Library File
Installation and un-installation of any software overwrite, remove, or sometime de-register libraries. In that case, simple functions like Date() or Trim() don’t work.
To see what libraries an Access Project is referenced, open any code window and choose the References option from the Tools menu.
It is possible for the file to be there in the reference list without being correctly registered in the registry. If you suspect such a case, then follow these steps to register the file.
- Click Start, and then go to the Search option after then click For Files and Folders.
- In the Search for files and folders named box, type exe.
- In the Look in box, tap the root of the hard disk.
- Select the checkbox Include Subfolders, if it is not selected and then click Find Now or Search Now.
- After getting the file, click Start<Run, and after this delete anything which is in the Open
- Drag the exe file from the search panel to the Open box.
- Repeat steps no. 2 to 6, but this time search for FileName.dll, where FileName is the file name that you want to register.
- When the FileName.dll file is in the Open box with the Regsvr32.exe file, tap to the OK.
- In Access, check whether the problem is actually.
If you don’t get this Regsvr32.exe file on your system then, check other computers for the file, you can also obtain this file from Microsoft Web site.
Method 3: Try Un-Register Or Re-Register The Library
If the library is marked missing, then click the Browse button and search for the file for the library.
If still the library is not shown, you may need to re-register it. For this, just follow these steps:
- Tap to the windows start button and select the run option.
- Now enter regsvr32followed with the full path of the library file.
- If the file name contains the spaces then include quotes, like this:
regsvr32 “c:\program files\common files\microsoft shared\dao\dao360.dll”
Sometimes, the problem is not get resolved until you re-register the library. So, first of all, unregister the library with this command and then follow the above one to re-register it again:
- Uncheck the missing library in access.
- Close access
- Issue this command to unregister the library :
regsvr32 -u “c:\program files\common files\microsoft shared\dao\dao360.dll”
- After this re-register it again with the above command and select the library reference again.
Use Professional Recommended Third-Party Access Database Repair Tool
If none of the above fixes comes in handy in fixing the compile error in Access, you can go for the recommended third-party tool- Access Repair N Recovery Tool. It has the ability to solve numerous unexpected errors and issues in MS Access.
The best thing about this program is- it can repair corrupted MS Access database (MDB or ACCDB) files.
Besides, it is very effective to recover tables, queries, reports, forms, macros, etc. So, just download and install this tool from the below-given button and start running it.
Here is the step-by-step guide of this tool:
Don’t forget to compile all modules after making adjustments in the references. To compile all the modules with the module still open, click to the Compile database on the Debug menu. If the modules don’t get compiled, there may be additional unresolved references.
In this article I have discussed Access compile error: Can’t find project or library briefly. You can easily troubleshoot this problem by applying the fixes mentioned here.
So, just try them and get rid of MS Access VBA can’t find project or library effectively.