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 may need updating when Access has just been upgraded or moved between machines running different versions of Microsoft Access.
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 (or Microsoft Office xx.x Access database engine)
Backup the database and decompile it with a command like this:
"C:\Program Files\Microsoft Office\Office14\MSACCESS.EXE" "C:\work\ss64.mdb" /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
Close Acces, back up and then delete the following registry key:
Adjust the path to match your version of Microsoft Office.
“Measuring programming progress by lines of code is like measuring aircraft building progress by weight” ~ Bill Gates