MenuBar Property

Microsoft Access Visual Basic

expression.MenuBar

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

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

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.

Example

The following example sets the MenuBar property to a menu bar named CustomerMenu:

Forms!Customers.MenuBar = "CustomerMenu"
		

To display the built-in menu bar for the form or the application global menu bar, you set the MenuBar property to a zero-length string (" ").

Forms!Customers.MenuBar = ""