Part IV: Professional Database Development
850
Note
When you choose Debug ➪ Compile Database Name, you see the name of your project. This is the name that
you used to save your database file the first time that it was created or saved. If you later rename the database
file, the project name doesn’t change. You can change it by choosing Tools ➪ Properties in the module window;
the database Properties dialog box contains the database name setting.
Access has a Background Compile option. Figure 24.1 shows this option under Compile on
Demand — the default value for this option is True (selected). This option tells Access to compile
code in the background rather than to compile it all at one time.
Tip
It is especially important to close your application after performing a Compile Database Name. To compile all your
modules, Access needs to load every module into memory. All this code stays in memory until you close Access.
Losing the compiled state
In the past, one of the greatest roadblocks to optimizing Access applications has been the fact that
an application could be uncompiled very easily. When the Access application was in an uncom-
piled state, Access had to constantly compile code as it was called. In fact, losing the compiled state
was so easy to do in previous versions of Access that it would often happen without developers
even realizing that they’d done it.
In Access 2010, only portions of code affected by certain changes are put into an uncompiled
state — not the entire application. By itself, this is a tremendous improvement over previous
versions of Access.
The following actions cause portions of your code to be uncompiled:
l (^) Saving a modified form, report, control, or module. (If you don’t save the modified object,
your application is preserved in its previous state.)
l (^) Adding a new form, report, control, or module, including adding new code behind a form.
l Deleting or renaming a form, report, control, or module.
l (^) Adding or removing a reference to an object library or database by using the References
command on the Tools menu.
Okay, so you think that you have a handle on code that loses its compiled state? Well, here are a
couple of gotchas to consider:
l (^) If you modify objects — such as reports or forms — at runtime through VBA code, por-
tions of your application are put into an uncompiled state when the objects are modified.
(Wizards often do this.)
l If your application creates objects like reports or forms on the fly, portions of your appli-
cation are put into an uncompiled state when the objects are created. (Wizards often do
this as well.)