3 4
In addition to moving commands around on built-in toolbars and menus and adding or deleting standard or custom commands, you can create your own custom toolbars, menu bars, and shortcut menus for use in a database. For example, you might have a set of special functions that perform actions related to a form or a set of forms in your database. You can create a custom toolbar with buttons to run these functions, or (if they are specific to a single form) you can place them as commands on a shortcut menu opened by right-clicking the form. A custom toolbar is the way to go if you need to run the custom functions from several different forms. Shortcut menus are preferable for commands specific to an individual form; you can even create a shortcut menu for an individual control on a form.
InsideOut
Although you can create a shortcut menu for a form control, doing so is rarely advisable. Form controls have many events that can be used to trigger procedures (GotFocus, LostFocus, BeforeUpdate, AfterUpdate, and others), and in almost all cases, you’re better off attaching code to one of these event procedures so that the code will run automatically when the event fires. If you do need to present users with a set of commands that apply to only a single control on a form, you’ll have to instruct them to right-click the control to open the shortcut menu, which is much less intuitive than automatically running a procedure when the control is selected (GotFocus) or when text in the control is changed (AfterUpdate).
Custom Access toolbars and menus are specific to the database in which they are created. To use a custom toolbar, menu, or shortcut menu in another database, you must import it into that database.
To import toolbars, menus, and shortcut menus into another database, follow these steps:
Figure 13-6. You can import your custom toolbars and menus into any other database in which you want to use them.
The custom toolbars and menus you create are local, but Access does provide two global toolbars: the built-in Utility 1 and Utility 2 toolbars. You can customize these toolbars as you want, and they’re available to all Access databases in an installation of Access—you don’t have to import them into another database.
Troubleshooting - I get a shortcut menu error message when I import a form with an attached shortcut menu
If you import a form with an attached shortcut menu into another database without separately importing the shortcut menu, you’ll get an error message (Microsoft Access can’t find the macro "ABC Shortcut Menu") when you right-click the form. (The word macro in this error message must be a holdover from earlier versions of Access, in which menus were created with a special type of macro.)
To fix this problem, import the shortcut menu into the current database. Its name will appear in the Shortcut Menu property in the form’s properties sheet.
Of course, if you keep adding buttons to the built-in toolbars, they’ll soon become large and unwieldy. If you don’t have a large monitor, tools might drop off the edge of a toolbar, and you’ll have to select them from the drop-down list of extra tools on the right (or bottom) of the toolbar. To prevent this inconvenience, and to organize your custom tools into logical groups, you can create custom toolbars or menus.
To create a new toolbar, follow these steps:
Figure 13-7. Give your custom toolbar a name that’s logical and easy to remember.
When you click OK, the new toolbar appears. The toolbar is easy to miss. Initially, it’s just a small square that might be located outside the Accesswindow, and its title bar is too small to display the full title. A newly created toolbar is shown in Figure 13-8.
Figure 13-8. This newly created Access toolbar isn’t too noticeable.
Figure 13-9. Add buttons to your custom toolbars on the Commands tab of the Customize dialog box.
If you’re not sure what a command does, select the command, and click the Description button to display a pop-up description, as shown in Figure 13-10.
Figure 13-10. Select a command, and click Description to see its pop-up description.
Figure 13-11. Drag a command to a new toolbar.
The default style for toolbar buttons is to display an image only, which is generally desirable. However, if you want a button to display text, or text and an image, right-click the button to open its properties sheet, and select a different style or change the button’s caption as described earlier in the section "Placing Custom Commands on Menus and Toolbars."
By default, Access has one menu bar, called simply the Menu Bar. However, you can create your own menu bars and add menus to them, as described in this section.
To create your own menu bar, follow these steps:
InsideOut
In Access 2002, the built-in menu bar has a default Ask A Question drop-down list. If you create a custom menu, the Ask A Question drop-down list is moved to the custom menu, which is particularly noticeable when the menu is undocked. The Ask A Question drop-down list now appears on the floating menu, and not on the built-in menu, which is probably not what you wanted. If you create more custom menus, the Ask A Question drop-down list remains on the first custom menu. Unlike other menu commands, you can’t drag the Ask A Question drop-down list to another menu.
You can remove the Ask A Question drop-down list by right-clicking the list and clearing the Show Ask A Question check box on the shortcut menu. (The Ask A Question drop-down list will disappear when you close the Customize dialog box.) However, this turns off the Ask A Question drop-down list completely. To turn on the Ask A Question drop-down list again, open the Customize dialog box, right-click the list, and select the Show Ask A Question check box on the shortcut menu.
If you have a custom menu docked on the right or left side of the Access window, you won’t see the Ask A Question drop-down list when the Customize dialog box is open. To turn this list on or off, first undock the menu so that the list appears.
Figure 13-12. Use the New Menu command to add a new menu to a menu bar.
Figure 13-13. Rename a new menu using the shortcut menu.
Now you can add selections to the new menu by dragging commands to it from the Commands list in the Customize dialog box. (The menu will drop down as you drag a command over it.) Figure 13-14 shows a third command being dragged to the Export menu on the ABC Menu menu bar.
Figure 13-14. Drag a command to a menu on a menu bar.
Set the menu’s other properties in its properties sheet, as you would for a toolbar button.
Access also allows you to add shortcut menus to interface objects—primarily forms and form controls—which enables you to create menus that are specific to forms (or reports in print preview) or to individual controls on forms.
To create a shortcut menu, follow these steps:
Figure 13-15. Naming a new shortcut menu for a form.
Figure 13-16. A message that includes steps on how to complete your custom shortcut menu appears when you create a shortcut menu.
Figure 13-17. Drag a command to a shortcut menu.
note