Microsoft Access Tips and Tricks
How to Decompile a Database
Decompiling is the act of telling Access to throw away the database's compiled VBA code -- not the readable source code, but the compiled instructions that the computer will actually follow -- thereby (hopefully) eliminating any corruption that may have crept into the compiled VB project so you can start fresh with a totally clean compile. Here's how to do it:
- With the database closed -- no users in it at all -- and (ideally) Access not running, make a backup copy, just in case something goes wrong.
- On the task bar, click Start -> Run... (or the equivalent in your current operating system).
- Enter this (adapted to match your database path and name) in the Run dialog box and click OK:
You may need to include the full path to msaccess.exe, but I don't find that to be the case when I try it. Hold down the Shift key as you click OK after typing in the line, to keep the database from trying to run any VBA code at startup. Depending on your Access version, you may not get any sign that anything in particular happened; you'll just see your database open in Access.
msaccess.exe /decompile "C:\Your Path To\YourDBName.mdb"
Note: it also works if you just enter:
and then open your database within the Access session that is started. The first database opened in a session started with the /decompile option is automatically decompiled.
- Compact and Repair your database.
- Open the database again, press Alt+F11 to switch to the VB Editor, and click Debug -> Compile (your project). If any errors appear, fix them and recompile.
- Close the VB Editor. Compact & Repair again.
At this point, your database has been decompiled, compacted to remove any lingering traces of the bad VB project, then recompiled and compacted again. If you were experiencing problems -- and you probably were or you wouldn't be decompiling -- try the database out now to see if the problems are gone.
Versions: Access 95 to 2010
Categories: VBA, How To
Date: 24 April 2012