Assigning Toolbars, Menus, and Shortcut Menus to Forms and Controls

3 4

If a menu bar or toolbar is not assigned to a specific database object, it will be displayed at all times (at least, if it’s checked in the Toolbars list in the Customize dialog box). This is desirable if the commands on the toolbar or menu bar can be used from several different forms (or all forms) in the database. Sometimes, however, you might need a toolbar or menu that has commands specific to a particular form, or even a specific control.

An order form, for example, might need a custom toolbar or menu with commands related to checking inventory or current prices for items. In this case, you can create a toolbar or menu and attach it to a form (or rarely, to a report) or to a form control. A form toolbar or menu only appears when the form is open; a report toolbar or menu appears when the report is previewed, and a control shortcut menu appears when the control is right-clicked. To attach a menu or toolbar to a form or report, follow these steps. (These steps describe attaching a menu or toolbar to a form; the procedure is the same for a report.)

  1. Open the form in Design view.
  2. Open the form’s properties sheet.
  3. Click the Other tab in the properties sheet.
  4. From the drop-down list for the Toolbar (or Menu Bar) property, select the toolbar or menu bar you want to attach to the form, as shown in Figure 13-18.

    figure 13-18.assign a custom menu to a form.

    Figure 13-18. Assign a custom menu to a form.

Now the custom menu you selected will be visible in Form view for this form only, as shown in Figure 13-19.

figure 13-19. this custom form menu is visible in form view for a specific form.

Figure 13-19. This custom form menu is visible in Form view for a specific form.

InsideOut

Although you can attach a toolbar or a menu bar to a form or control, it might not be intuitively apparent that the toolbar (or menu bar) belongs to the form, because a command bar can be either free-floating or docked at one of the edges of the Access window but it can’t be docked to the top of a form. A shortcut menu clearly belongs to only one object, however, so you should use shortcut menus rather than toolbars or menu bars when you need to display a selection of commands relevant to only a particular form.

A custom shortcut menu is designed to pop up when a specific object (usually a form or a control on a form) is right-clicked, just like the built-in shortcut menus. Shortcut menus are handy places to assign commands that apply to only a specific form or control, such as checking the current price of an item before finalizing an order or selecting one of a set of filters for form data. Shortcut menus are object-specific, so you must assign your newly created shortcut menu to a database object for it to be useful. As with amenu or toolbar, you assign a shortcut menu to a form by using the Shortcut Menu Bar property, shown earlier in Figure 13-18.

To assign a shortcut menu to a specific control on a form, open the properties sheet for the control, and select the shortcut menu from the list in the Shortcut Menu Bar property, as shown in Figure 13-20.

figure 13-20. assign a shortcut menu to a control to enhance that control’s usefulness.

Figure 13-20. Assign a shortcut menu to a control to enhance that control’s usefulness.

Now the custom shortcut menu replaces the default shortcut menu for this control when you right-click the control, as shown in Figure 13-21.

figure 13-21. the custom shortcut menu for a control replaces the default shortcut menu.

Figure 13-21. The custom shortcut menu for a control replaces the default shortcut menu.

Creating Global Menu Bars and Global Shortcut Menu Bars

You can designate a global menu bar or a global shortcut menu bar in the Startup dialog box. Figure 13-22 shows a database’s Startup dialog box, with the ABC Menu designated as the global menu bar and the default selection for the shortcut menu bar.

figure 13-22. select a custom menu bar for a database in the database’s startup dialog box.

Figure 13-22. Select a custom menu bar for a database in the database’s Startup dialog box.

When you’re working in code, you can designate a global menu bar or shortcut menu bar by setting the Menu Bar or Shortcut Menu Bar property of the Access Application object to the desired menu bar or shortcut menu.



Microsoft Access Version 2002 Inside Out
Microsoft Access Version 2002 Inside Out (Inside Out (Microsoft))
ISBN: 0735612838
EAN: 2147483647
Year: 2005
Pages: 172
Authors: Helen Feddema

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net