Using a COM Addin

Using a COM add-in is easy: just click the button it placed on the Add-Ins tab of the Ribbon, as shown in Figure 13.8. To rename controls on any open Access forms, for example, open a form in design view, and click the Rename Form Controls button on the Add-Ins tab. You will first get a message asking if you want to save the original control names to their Tag property, as shown in Figure 13.13.

FIGURE 13.13

A COM add-in question.

FIGURE 13.13

A COM add-in question.

Saving the original control name to the Tag property can occasionally be useful, especially when you are renaming controls in a database created by someone else, and you may need to know the original control name in order to fix a reference later on. However, the default choice is No, because mostly there is no need to save the original control name.

After selecting a choice, the code then proceeds to cycle through the open forms and, for each form, cycle through its controls. For any control that doesn't have the appropriate control prefix, a new name is created, and presented for approval in a message box, as shown in Figure 13.14.

FIGURE 13.14

A proposed new control name.

FIGURE 13.14

A proposed new control name.

Generally, the new name can be accepted as is; occasionally (for example, for labels with very lengthy captions, or controls with expressions), the new name needs to be edited, which is done by clicking No and then editing the control name in an InputBox.

Even in Access 2007, when you create a new bound form using the Form button in the Create tab of the Ribbon, all bound controls will have the same names as their fields, which can lead to circular reference errors when running code. Thus, it is a good idea to run the Rename Form Controls (or Rename Report Controls) command immediately after creating a bound form or report, before writing any code that references its fields or controls.

0 0

Post a comment