M.5. Display Informative Form Captions

If you don't set your own form captions, Access just displays the form name there, as shown in Figure M-6.

Figure M.6. Figure m-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 touch for the caption is to indicate which back-end database you are currently using. That way, your users know instantly whether they're in the Production or Test database, for example.

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

Figure M.7. Figure m-7

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

Figure M.8. Figure m-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™ 2007 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.