Run-time Error 5 "Invalid Procedure Call or Argument"

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.

1) VBA References

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)

2) Rebuild

Create a new database file and import all the objects into it.

3) Decompile

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

4) Registry

Close Access, back up and then delete the following registry key:
[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access]
Adjust the path to match your version of Microsoft Office.

5) Reinstall the latest Microsoft Office service pack.

6) Corrupt form

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

 


© Copyright SS64.com 1999-2014
Some rights reserved