DoCmd.AddMenu Method (Access)

Office 2010

The AddMenu method carries out the AddMenu action in Visual Basic.

.AddMenu(MenuName, MenuMacroName, StatusBarText)

A variable that represents a DoCmd object.

Parameters

Name

Required/Optional

Data Type

Description

MenuName

필수

Variant

A string expression that's the valid name of a drop-down menu to add to the custom menu bar or global menu bar. To create an access key so that you can use the keyboard to choose the menu, type an ampersand (&) before the letter you want to be the access key. This letter will be underlined in the menu name on the menu bar.

MenuMacroName

필수

Variant

A string expression that's the valid name of the macro group that contains the macros for the menu's commands. This is a required argument.

StatusBarText

필수

Variant

A string expression that's the text to display in the status bar when the menu is selected.

You can use the AddMenu action to create:

  • A custom menu bar for a form or report. The custom menu bar replaces the built-in menu bar for the form or report.

  • A custom shortcut menu for a form, form control, or report. The custom shortcut menu replaces the built-in shortcut menu for the form, form control, or report.

  • A global menu bar. The global menu bar replaces the built-in menu bar for all Microsoft Access windows, except where you've added a custom menu bar for a form or report.

  • A global shortcut menu. The global shortcut menu replaces the built-in shortcut menu for fields in table and query datasheets, forms in Form view, Datasheet view, and Print Preview, and reports in Print Preview, except where you've added a custom shortcut menu for a form, form control, or report.

You must include the menuname and menumacroname arguments in the AddMenu method for custom menu bars and global menu bars. The menuname argument is not required and will be ignored for custom shortcut menus and global shortcut menus.

The statusbartext argument is optional, this argument is ignored for custom shortcut menus and global shortcut menus.

표시: