Creating Custom Command Bars in the Interface

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).

Creating Localized and Global Menus and Toolbars

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:

  1. Choose File, Get External Data, Import.
  2. Select the database containing the toolbar or menu in the Import dialog box, and click Import.
  3. Click the Options button in the Import Objects dialog box, and select the Menus And Toolbars check box, as shown in Figure 13-6. Then click OK.

    figure 13-6. you can import your custom toolbars and menus into any other database in which you want to use them.

    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.

Managing Your Toolbars

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:

  1. Open the Customize dialog box by right-clicking the gray background of a toolbar and selecting Customize from the shortcut menu.
  2. Click the Toolbars tab, and then click New.
  3. Give the new toolbar a name, as shown in Figure 13-7, and click OK to close the New Toolbar dialog box.

    figure 13-7. give your custom toolbar a name that’s logical and easy to remember.

    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-8. This newly created Access toolbar isn’t too noticeable.

  4. To add a button to the toolbar, click the Commands tab of the Customize dialog box, shown in Figure 13-9.

    figure 13-9. add buttons to your custom toolbars on the commands tab of the customize dialog box.

    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-10. Select a command, and click Description to see its pop-up description.

  5. Select a category for commands, and then drag the command you want to use from the Commands list to the toolbar. Figure 13-11 shows a formatting command being added to the newly created toolbar. Close the Customize dialog box when you’ve finished adding commands.

    figure 13-11.drag a command to a new toolbar.

    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."

Creating Custom Menu Bars

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:

  1. Open the Customize dialog box by right-clicking the gray background of a toolbar and selecting Customize from the shortcut menu.
  2. Click the Toolbars tab, and then click New.
  3. Give the new toolbar a name, and then click OK in the New Toolbar dialog box.
  4. Select the new toolbar in the Toolbars list, and click the Properties button to open its properties sheet.

    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.

  5. Select Menu Bar from the Type drop-down list. This is the point at which the toolbar becomes a menu bar.
  6. You can change other properties for the menu bar in the properties sheet. For example, you can prevent the menu bar from being moved or hidden, or show it on the Toolbars menu. When you have set all the properties you need to set, close the properties sheet.
  7. Click the Commands tab of the Customize dialog box.
  8. To add a menu to the new menu bar, select New Menu from the bottom of the Categories list and then drag New Menu from the Commands list to the new menu bar, as shown in Figure 13-12.

    figure 13-12.use the new menu command to add a new menu to a menu bar.

    Figure 13-12. Use the New Menu command to add a new menu to a menu bar.

  9. Right-click New Menu on the menu bar, and use the shortcut menu to give the new menu a new name, as shown in Figure 13-13.

    figure 13-13.rename a new menu using the shortcut menu.

    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.

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.

Adding Shortcut Menus

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:

  1. Open the Customize dialog box by right-clicking the gray background of a toolbar and then clicking Customize on the shortcut menu.
  2. Click the Toolbars tab, and then click New.
  3. Give the new toolbar a name, and then click OK in the New Toolbar dialog box, as shown in Figure 13-15.

    figure 13-15.naming a new shortcut menu for a form.

    Figure 13-15. Naming a new shortcut menu for a form.

  4. Select the new toolbar in the Toolbars list, and then click the Properties button to open its properties sheet.
  5. Select Popup from the Type drop-down list.
  6. An informative message appears, as shown in Figure 13-16. Click OK to close the message box.

    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-16. A message that includes steps on how to complete your custom shortcut menu appears when you create a shortcut menu.

  7. As described in the message box, the next step is to display the menu. To do so, check the check box to the left of Shortcut Menus in the Toolbars list in the Customize dialog box.
  8. Click Custom in the Shortcut Menus toolbar that appears. You’ll see the new shortcut menu.
  9. Drag commands from the Commands tab of the Customize dialog box to the shortcut menu on the Custom menu, as shown in Figure 13-17.

    figure 13-17.drag a command to a shortcut menu.

    Figure 13-17. Drag a command to a shortcut menu.

note


You might have to move the Shortcut Menus toolbar to the left to be able to see enough of your shortcut menu to add commands to it.



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