Monday, April 6, 2009

How Do I Decompile a Database?

Decompiling An Access Database

In order for any program code to be run by a computer, it must be converted to machine-readable code. This code is called Object Code. The text version of this program that you and I can read is called Source Code.

In Access, the process of producing Object Code from Source Code is called "compilation". Whenever code is run for the first time in Access, the code is first compiled. (You can also compile it yourself by pushing the compile button). The only place you can make changes to code is in the Source Code, which must again be compiled into Object Code.

Occasionally, code can be deleted from the Source Code, but for some reason is never removed from the Object Code. This code is never again seen on the screen as text, but is still sitting there somewhere in the database file. This can, at times, interfere with the normal operation of the program.

To remove these stray bits of code, you can "Decompile" your database and then re-compile it. This process removes all of the compiled Object Code, then when you re-compile it, you only get Object Code that reflects the current Source Code.

To Decompile your Access database, do the following:

  1. Click the Start button on the task bar and choose Run
  2. In the Run dialog box, type the following:
    "C:\Program Files\Microsoft Office\Office\Msaccess.exe" /decompile
    where the first part (in quotes) is the complete path to your Access program. If you have the default installation, it is likely that it is just as listed here. Click OK.
    Note: if you have Windows Vista, just type the command line in the Start Search box of the Start menu.
  3. This will open Access and allow you to choose which database to open. Whichever database you open will be decompiled.
  4. Choose a database and open it. Access 97 used to give you a dialog which told you the database had been decompiled, but newer versions do not. Nevertheless, the database has been decompiled.
  5. Open any Module in design view, or any Form or Report in design view and choose View > Code from the menu. In the next screen, choose Debug > Compile from the menu bar.
    Note: In Access 2007, you can also choose Database Tools on the ribbon, then select Visual Basic. Then choose Debug > Compile.
  6. Your database has now been Decompiled and Re-compiled.

Creating a Shortcut:

I use decompile quite frequently, so instead of typing the command line into the Run box, I've created a shortcut on my desktop. There are several ways to create a shortcut, the easiest is to use the Shortcut Wizard.

Right-click anywhere on your desktop and select New > Shortcut. The wizard will give you a dialog box allowing you to browse to the file you want. It should be the same as above in Step 2. Once you've browsed there, add the "/decompile" switch to the end as shown below. Be sure to separate the decompile switch from the file path with a space. It will look as follows:


Click Next.

It will ask to name your shortcut. Choose something descriptive like Decompile Access 2003. And click Finish.

The finished shortcut will look like this:


Now when I want to decompile a database, I just click the shortcut and start with Step 3 above.


.

Thursday, March 26, 2009

New Sample: Form_MoveTabControl

Form_MoveTabControl

by A.D. Tejpal

Sample Db - Explanatory Notes

This sample db demonstrates movement of tab control to any desired location, along with all its controls located on various pages.

Conventional approach to moving a control does not suit a tab control, as the controls contained in it stay put at their current locations. As a result, one can land up with a badly deformed tab control, in an effort not to let go of any control.

A workaround for ensuring correct movement of tab control, along with all its controls, without resorting to custom built collection or array, is demonstrated in this sample db.

Version: Access 2000 File Format

You can find the sample here: http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=448

.

Thursday, March 19, 2009

New Sample: Reports_AddIn_2

Reports_AddIn_2

by A.D. Tejpal

Sample Add-In - Explanatory Notes

General: This Add-In is meant to utilize a set of common reports belonging to the Add-In, in various db's. Queries in host db are used as record source for such reports. On activation of the Add-In, names of reports belonging to the Add-In are shown in a list box at left, while names of queries available in host db are displayed in list box at right.

For a given report selected in left list box, the user can select an appropriate query in right list box. The selected report will open, using selected query as its record source.

Version: Access 2000 File format
Reference Required: DAO 3.6

You can find the sample here: http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=447

.

Tuesday, March 17, 2009

New Sample: Form_UnBound_UnDoReDo

Form_UnBound_UnDoReDo

by A.D. Tejpal

Sample Db - Explanatory Notes

General:
This sample db demonstrates Undo / Redo features while entering / editing data through an unbound form. Use of collections for storing control and field values respectively, facilitates the process.

Adding a new record:
Clicking the Add command button presents a simulated new record in distinct back color (indicative of new record). As soon as it is made dirty, Save and Undo command buttons become enabled. Clicking Save adds the record to source table and back color changes confirming the process. If, instead of Save, Undo is clicked, the existing entries get ignored, and fresh blank new record is presented.

Editing an existing record:
Based upon selection in combo box, the controls get populated with the contents of desired record, with a back color distinct from that for new record. As soon as the record is made dirty (by making change in any of the controls), Save and Undo buttons get enabled.
Clicking the Undo button restores the original values and simultaneously, Redo button gets enabled (accompanied by disabling of Undo button). Clicking the Redo button restores the values back to recently edited ones. Simultaneously, Undo button gets enabled (accompanied by disabling of Redo button). The user can shuttle between the Undo & Redo buttons as often as desired. Different back colors confirm Undo / Redo actions.

Clicking Save button saves the record as edited.

Deleting records:
Clicking the Delete button deletes the selected record. At the same time, autonumber for source table gets reset suitably so that next one will get generated in sequence, without leaving any holes.

Version: Access 2000 File Format

You can find the sample here: http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=446

.