MenuBar Property

MenuBar Property

See Also         Example         Applies To

You can use the MenuBar property to specify the menu bar to use for a Microsoft Access database (.mdb), Access project (.adp), form, or report. You create these menu bars by using the Customize subcommand of the Toolbars command on the View menu. For more information on creating customized toolbars, see Create a custom menu bar for the current database.

You can also use the MenuBar property to specify the menu bar macro that will be used to display a custom menu bar for a database, form, or report.

Note   In previous versions of Microsoft Access, you created a custom menu bar by setting the MenuBar property to the name of a menu bar macro. You then created macro groups containing the commands for the menus on this menu bar. This functionality is still supported in Access9TBD. However, it is strongly recommended that you create custom menu bars with the new Customize dialog box, available by clicking Toolbars on the View menu.

Setting

Enter the name of the menu bar you want to display. If you leave the MenuBar property setting blank, Microsoft Access displays the built-in (default) menu bar or the application's global menu bar. If you set the MenuBar property to a value that is not the name of an existing menu bar or menu bar macro, the form or report will not have a menu bar (the default menu bar will not be shown).

You can set this property by using the object's property sheet, a macro, or Visual Basic.

In Visual Basic, set this property by using a string expression that is the name of the menu bar you want to display.

To display the built-in menu bar or global menu bar for a database, form, or report by using a macro or Visual Basic, set the property to a zero-length string (" ").

Remarks

When you use the MenuBar property with forms and reports, Microsoft Access displays the specified menu bar when the form or report is opened. This menu bar is displayed whenever the form or report has the focus.

When used with the Application object, the MenuBar property enables you to display a custom menu bar throughout the database. However, if you've set the MenuBar property for a form or report in the database, the custom menu bar of the form or report will be displayed in place of the database's custom menu bar whenever the form or report has the focus. When the form or report loses the focus, the custom menu bar for the database is displayed.

Note   You can switch between a database's custom menu bar and the built-in menu bar by pressing CTRL+F11.