Access Database Right-Click Context Menu Creator
Wouldn't it be great to right-click an Access file to compact or decompile it? With Daniel Pineault's awesome tool, you can!
A common Microsoft Access troubleshooting technique is to use the undocumented /decompile
command-line switch.
This will remove the compiled byte code from an Access application, forcing Access to recreate the byte code from the original VBA source code. This approach fixes a specific type of corruption where the compiled byte code and the original VBA source code get out of sync. From experience, those types of errors (though rare) seem to get introduced when using the Edit and Continue feature of VBA, especially when editing code-behind on forms and reports.
The problem with this technique is that it traditionally requires you to actually open a cmd
window, type out the full path to msaccess.exe
, then type out the full path to your .accdb
file, and finally, include the /decompile
switch.
A Simpler Way
Access MVP Daniel Pineault wrote a tool in Access to add the decompile switch (and other common Access commands) to the Explorer context (a.k.a., right-click) menu.
Here's the end result:
You can download the tool from Daniel's site: Windows Explorer MS Access Database Right-Click Context Menu.
Pulling Back the Curtain
So, what does the tool actually do?
It's an .accdb, so you can look behind the scenes yourself if you would like (just hold down the Shift key when opening the file). In fact, Daniel explicitly allows/encourages this in the comments section:
Since the database is unlocked, feel free to develop [additional] features and I’ll be more than happy to update the sample and give credit where credit is due!
But, to save you that trouble, I'll provide a brief overview:
- For each selected extension (*.accdb, *.accde, etc.), look up the application class name in
HKCR\.accd*
- Add an entry for each app class name to
HKCU\SOFTWARE\Classes\
- Create a
shell\CARDA Database Tools\shell
entry under the app class name - For each selected command (/decompile, /compact, etc.), create a
Decompile\command
entry - In the
command
entry, set a (Default) value ofmsaccess.exe %1% /decompile
Here are some associated screenshots:
Removing the Items from the Context Menu
In the comments, someone asked how to remove items from the context menu.
Daniel's tool does not automate the process, but as he states in his response, it's very straightforward. You just have to know which registry entries to delete. 😉
To save you the hassle of figuring this out for yourself, I did a bit of legwork.
To completely remove the context menu items, you just need to delete the registry entries highlighted in the red box below. They are all found under the HKCU\SOFTWARE\Classes\
registry key. Once again, your registry items may be slightly different than the ones shown below due to differences in Access versions.
I was initially nervous about deleting the above registry keys, so I checked on a different computer that had Access installed where I had not run Daniel's tool. Those keys did not exist at all, so I felt comfortable deleting them on my current computer.
Tip o' the hat to Colin Riddington for highlighting Daniel's tool in one of his recent articles, Access Command Line Switches.