| | Product Information Help and How-to Training Templates Support and Feedback Technical Resources Additional Resources | Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.
Create custom menus and shortcut menus by using macros
You can use Access macros to create custom shortcut menus that appear when you right-click forms, reports, or individual controls. You can also create custom menus that appear on the Ribbon for specific forms or reports.
To create a menu by using macros, you perform three main steps:
- Create a macro group that defines the menu commands.
- Create another macro that creates the menu itself.
- Attach the menu to a control, a form, a report, or to the database as a whole.
The following sections walk you through these steps in detail.
Step 1: Create a macro group that contains the menu commands
In this step, you create a macro group, each macro of which will be a separate command on your shortcut menu. What is a macro group? A macro group is a single macro object that contain two or more independent macros. The individual macros are identified by typing a name for each macro in the Macro Names column. In the following illustration, Macro3 is a macro group. NotFoundMsg and FoundMsg are individual macros within the group, each macro consisting of two macro actions.
Note The Macro Name column is hidden by default. To display the Macro Name column, on the Design tab, in the Show/Hide group, click Macro Names.
- On the Create tab, in the Other group, click Macro. If this command is unavailable, click the arrow beneath either the Module or the Class Module button, and then click Macro.
- On the Design tab, in the Show/Hide group, click Macro Names to display the Macro Name column.
- For each command that you want on your custom Shortcut Menu:
- In the Macro Name column, enter the text that you want to display on the shortcut menu (for example, "Print report" or "Save").
Note To create an access key so that you can use the keyboard to choose the command, type an ampersand (&) before the letter that you want to be the access key in the command name (for example, "&Save"). This letter will be underlined on the menu.
- In the Action column, select the first action you would like to take place when you click the command on the shortcut menu.
- If there are more actions that you want to take place when you select this command, add them on the subsequent lines. For each subsequent action, leave the Macro Name cell blank.
Note To create a line between two menu commands, type a hyphen (-) in the Macro Name column between the appropriate menu commands.
- Save and name the macro, for example, mcrShortcutMenuCommands.
The following illustration shows an example macro group for a custom menu or shortcut menu.

Step 2: Create a macro that creates the menu
This step might seem redundant, but to create the shortcut menu from the macro group that you created in Step 1, you must create a second macro that contains the AddMenu macro action. This macro is sometimes called the "menu macro".
- On the Create tab, in the Other group, click Macro. If this command is unavailable, click the arrow beneath either the Module or the Class Module button, and then click Macro.
- On the first line of the macro, select AddMenu in the Action list.
- Under Action Arguments, in the Menu Name box, type the name of the menu (for example, "Report Commands"). This argument is not required, but is recommended if, in Step 3, you plan to add the menu to a Ribbon tab (such as the Add-Ins tab of a form or report). If the menu is added as a shortcut menu in Step 3, the Menu Name argument is ignored.
- In the Menu Macro Name box, enter the name of the macro that you created in Step 1.
- Save and name the macro, for example, mcrAddShortcutMenu.
The following illustration shows an example menu macro that creates the menu we designed in Step 1.

Step 3: Attach the menu to a control, form, report, or database
Depending on where you want the menu to appear, use one or more of the following procedures.
-
Add the menu to the Add-Ins tab of a form or report
Use this procedure if you want the menu to appear on the Add-Ins tab for a specific form or report, as shown in the following illustration:

- In the Navigation Pane, right-click the form or report where you want the menu to appear, and then click Design View.
-
On the Design tab, in the Show/Hide group, click Property Sheet.
- Select the entire object by selecting Form or Report from the list at the top of the Property Sheet task pane.
- On the Other tab on the Property Sheet, in the Shortcut Menu property box, type the name of the macro that you created in Step 2 (in this example, “mcrAddShortcutMenu”).
The next time you open the form or report, the Add-Ins tab appears in the Ribbon. Click the tab to see the menu.
For more information about Ribbon customization techniques, such as adding custom tabs or hiding the default tabs, see the article Customize the Ribbon.
The Ribbon is a component of the Microsoft Office Fluent user interface.
-
Add the menu as a shortcut menu for a form, report, or control
Use this procedure if you want the menu to appear when you right-click a specific form, report, or control, as shown in the following illustration:

- In the Navigation Pane, right-click the form or report where you want the shortcut menu to appear, and then click Design View.
-
On the Design tab, in the Show/Hide group, click Property Sheet.
- Select the control or object to which you want to attach the shortcut menu.
Note To select the entire object, select Form or Report from the list at the top of the Property Sheet task pane.
- On the Other tab on the Property Sheet, in the Shortcut Menu Bar property box, type the name of the macro that you created in Step 2 (in this example, “mcrAddShortcutMenu”).
-
Add the menu as a global shortcut menu
This procedure replaces all of the default shortcut menus in the current database. Custom shortcut menus that you have attached to specific forms, reports, or controls are not affected.
- Click the Microsoft Office Button
and then click Access Options.
- In the Access Options dialog box, click Current Database.
- Under Ribbon and Toolbar Options, in the Shortcut Menu Bar box, type the name of the macro that you created in Step 2 (in this example, “mcrAddShortcutMenu”).
Notes
Top of Page
|