Create Menus with Macros
We have learned how to create Menus and Toolbars through Toolbars – ->Customize options earlier. If you would like to have a second look at them then the links are given below:
- Select the Macro Tab on the Objects pane.
- Click New to open a new Macro in Design View.
- If the Macro Name Column is not visible then click on the Macro-Name Toolbar Button (with xyz label) to display the Macro Name Column.
- Type Clo&se under the Macro Name column in the first row.
- Select Close from the drop down list of Action.
- Type &Preview in the second row under Macro Name.
- Under Action select OpenReport from the drop-down list.
- In the Property Sheet under Action Arguments select a Report from your list of Reports (I have selected Employees in the sample image given above) in the Report Name Property.
- Select Print Preview in the View Property.
- Type &Form in the third row under the Macro Name column.
- Select Open Form in the Action Column.
- Select an existing Form's name from the Form Name Property drop-down list.
- Select Form in the View property.
- Type a dash (–) character in the next row under Macro Name column.
- Type &GotoNext in the fifth row under Macro Name column.
- Select GotoRecord in the Action Column.
- Type &Minimize in the sixth row under Macro Name.
- Select Minimize from the drop-down list in Action Column.
- Save the Macro with the name mcrShortCut and close it.
You can add as many commands or actions like opening Queries or running Programs etc. can be added to your menu for the convenience of your Application Users.
Our work on the Macro Menu is complete, but a little more work is left to define the Macro as a Menu.
- Open a new macro in design view.
- Select AddMenu from the drop-down list in Action Column.
- Leave the Menu Name Property Blank. This is used for Group Menu Names when you have group Menus with different set of actions. In this case this Macro will have more than one AddMenu Action lines with different set of Menu Macros.
- Select mcrShortCut in the Menu Macro Name Property.
- Save the macro with the name mcrShortCutMenu.
- Open one of your Forms in Design View (don't open the Form that you have used in the OpenForm action in the first macro).
- Display the Form's Property Sheet (View – ->Properties).
- Set the following Property Values of the Form as given below:
- Shortcut Menu = Yes
- Shortcut Menu Bar = mcrShortCutMenu
- Save the Form.
- Open the Form in normal view.
- Right-Click on the Form to display the Shortcut Menu. See the sample image given below:
Try out options displayed in the Shortcut Menu.
We can not only create Shortcut Menus but also Toolbars and Menu Bars too. This we will learn Next.
Change Secure DB to Unsecured
Date and Time Values
Limit to List Combo Box
Input Masks and Data Entry
Menus with Option Group Control