I.4. Display Informative Form Captions

If you don't set your own form Captions, Access will just display the form name there, as shown in Figure I-6.

This is a sure sign of a novice developer. You need to at least replace the Caption with the name of your application. One nice additional feature for the Caption is to indicate which back-end database you are currently using. That way, your user knows instantly whether they are in the Production or Test database, for example.

Figure I.6. Figure I-6

You'll need a table in the back-end database to store system-wide configuration values. In this example, it is named tsysConfig_System, and it contains a field containing the name of the database (see Figure I-7).

Figure I.7. Figure I-7

You'll also need a local table in the front-end MDB to store static values for the application itself, as shown in Figure I-8. In our example, one of the fields is the name of the application, suitable for showing on various forms throughout the system.

Figure I.8. Figure I-8

The code to set the Caption is easy. It belongs in the Open event code behind every form:

Me.Caption = DLookup("ApplicationTitle", "tsysConfig_Local") _ & " - " & DLookup("SysConfigDatabaseName", ...

Get Access 2003 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.