3 4
I’ve written several application-specific add-ins for Access as well as one COM add-in that runs in Access. Chapter 21, "Creating Your Own Add-Ins," describes how I created the LNC Rename Access add-in and the LNC Rename COM add-in. In this section, you’ll learn how to use these add-ins and one other in the Access interface.
You can create your own add-ins to save time or add functionality to Access. To find out how, see Chapter 21, "Creating Your Own Add-Ins."
The add-ins referenced in the following sections appear on the companion CD
The LNC Rename add-in allows you to apply the Leszynski Naming Convention (LNC) to existing objects in a database. The LNC Rename add-in includes three menus for renaming database objects and controls on forms and reports plus two builders for renaming an individual control or all controls on a form or report.
See Chapter 20, "Customizing Your Database Using VBA Code," for details on the LNC.
To install the LNC Rename add-in, follow these steps:
Three selections now appear on the Add-In menu (Rename Form Controls, Rename Report Controls, and Rename Database Objects).
The LNC Rename add-in uses the Find and Replace add-in for some chores (renaming database objects in particular). (Find and Replace is an Access add-in created by Rick Fisher; a 30 day trial version of Find and Replace is included in the Third-Party Add-Ins section of the companion CD.) If you already have Find and Replace version 9.00e installed, you’re all set; otherwise, follow these steps to install Find and Replace:
Now you’re ready to use the LNC Rename add-in. It will invoke Find and Replace as needed to rename references to database objects.
You can use the Rename Database Objects command to apply the LNC to a database that’s totally devoid of a naming convention. The sample database used to demonstrate the LNC Rename add-in is Event Management.mdb. Event Management.mdb is a database created using the Access Database Wizard. Because the wizard doesn’t use any naming convention when it creates database objects and controls, the database needs extensive renaming.
To use Rename Database Objects to apply the LNC, follow these steps:
Figure 15-33. On the Choose Database Object form, select the type of database object to rename.
tip
Figure 15-34. The tables in a database are renamed with the LNC tbl tag.
Figure 15-35. Some of the proposed name changes might be inappropriate.
After renaming all the database objects, you can run the Rename Form Controls and Rename Report Controls commands to rename controls on all forms or all reports. To rename controls on all forms, follow these steps:
Figure 15-36. In the Forms To Rename dialog box, you select forms whose controls you want to rename.
The default button is No, to not save the original control name to the Tag property. Generally, this is the appropriate choice. However, if you have some reason to preserve the original control names, click Yes.
If you want to rename a single control on a form, you can use the LNC Rename Current Control builder. To do so, follow these steps:
Figure 15-37. To rename a control, click the Build button next to its Name property on its properties sheet.
Figure 15-38. The Choose Builder dialog box lists the two LNC builders.
InsideOut
By default, Access gives a bound control the same name as its field. This can lead to circular reference errors, so it’s especially important to rename bound controls in order to avoid confusion with fields of the same name.
See Chapter 6, "Working with Form Controls," for more information about circular reference errors.
To rename all controls on the current form or report, you can use the LNC Rename All Controls builder. To use this builder, open the detail section’s properties sheet, and click the Build button next to the Name property. In the Choose Builder dialog box, click LNC Rename All Controls and click OK. The builder will display a message suggesting a new name for each control in turn.
I wrote the LNC Rename COM add-in to fill a gap between the Rename Form Controls (or Rename Report Controls) commands and the LNC Rename All Controls in the Choose Builder dialog box. The LNC Rename COM add-in renames form controls or report controls on all currently open forms or reports. This add-in places a Rename Controls button on the Form Design and Report Design toolbars for quick access, as shown in Figure 15-39.
Figure 15-39. The Rename Controls button lets you quickly rename the controls on a form or a report.
You can click the Rename Controls button to cycle through all controls on all open forms or reports, renaming each control, and displaying the same message box as for the Access add-ins. The LNC Rename COM add-in is located on the companion CD and is named LNC Rename.dll. For instruction on how to install, see the section "Installing a COM Add-In" earlier in this chapter.
The Menu Manager add-in creates a main menu for an Access application, with drop-down lists for selecting database objects. It consists of three menu add-ins, one for creating the main menu and two for doing housekeeping chores later on. To install and test the add-in, follow these steps:
note
Figure 15-40. Select a sidebar picture for the main menu.
Figure 15-41. The new main menu lets users select forms and reports or create Word letters.
On the main menu, the Orders button opens the application’s primary form (which is identified by the fpri tag). (The form name can also be hard-coded if you don’t want to use this tag.) The other forms in the database are accessed via the Other Forms drop-down list, and the reports are accessed via the Reports drop-down list, as shown in Figure 15-42. Reports are listed by their captions, with a prefix indicating the paper size. These combo boxes are based on lookup tables that the add-in filled with form and report data.
Figure 15-42. Users can select a report from the main menu’s Reports drop-down list.
The Word Letters drop-down list lets users select a Word letter to fill with data from Access. Users can select recipients from the Recipients drop-down list. This part of the interface requires some coding to select your Word templates and the specific data you want to export to Word.
After adding or deleting forms or reports, you can refresh the form and report look-up tables by choosing Tools, Add-Ins and then clicking Refresh Lookup Tables.