In Microsoft Access the error "Invalid Procedure Call or Argument" (sometimes followed by a "File Not Found" Error ) can have several possible causes. One or other of the remedies below will usually resolve this.
These references might need updating when Access has just been upgraded or moved between machines running different versions of Microsoft Access. It is a good idea to document the references that you use.
To see the libraries an Access project has referenced, open any code window (Ctrl+G), and choose Tools ➞ References
If any references display "MISSING REFERENCE", make a note of the name, uncheck it and then scroll down to find an equivalent valid reference, most often a slightly newer version.
The essential references are:
Visual Basic For Applications
Microsoft Access xx.x Object Library
Microsoft DAO 3.x Object Library
Microsoft Office xx.x Access database engine
Those will allow you to write VBA code, address built-in access objects (forms etc) and read/write to ACCDB/MDB file respectively. Access will not let you remove these 3 libraries from your database.
Other very common references:
OLE Automation (Fonts, Pictures)
Microsoft Office xx.x Data Access Components Installed Version
(ActiveX Data Objects/ADO, OLE DB, and ODBC)
Compile all modules after adjusting references.
Backup the database and decompile it with a command like this:
"C:\Program Files\Microsoft Office\Office16\MSACCESS.EXE" "C:\work\ss64.accdb" /decompile
Adjust the path to match your database and version of Microsoft Office.
If the database contains any startup code hold down the shift key to bypass it.
Once the database has been decompiled, close the Access instance completely.
Open a new Access instance, again hold down the shift key to bypass any startup code, and then compact and repair the database.
You can now recompile the VBA code by opening any module and selecting Debug ➞ Compile
Create a new database file and import all the objects into it.
It is possible for the metadata around Access forms to become corrupt, make a backup of the entire Access database, delete the last few forms that have been edited (making a careful note of the names). Now copy and paste the form(s) back from the backup copy, n.b. don't use the import feature. This will rebuild the metadata around the form.
“Measuring programming progress by lines of code is like measuring aircraft building progress by weight” ~ Bill Gates
Q825796 - Access References that you must set (2003)