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", "tsysConfig_System")

Now, when each form opens, you can set the Caption to the title of the application, concatenated with the name of the back-end database, as in Figure I-9.

By setting the caption of every form, you avoid the rookie move of showing an internal form name like "frmBusinesses" in the caption. And by using a configuration table to supply the application name, you avoid hard-coding it in every form. This will make your job a lot easier for each application you develop, as you won't have to change this code in every table—only the value in the one table.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.95.248