편집

다음을 통해 공유


DoCmd.AddMenu method (Access)

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

Syntax

expression.AddMenu (MenuName, MenuMacroName, StatusBarText)

expression A variable that represents a DoCmd object.

Parameters

Name Required/Optional Data type Description
MenuName Required 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 Required 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 Required Variant A string expression that's the text to display in the status bar when the menu is selected.

Remarks

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.

  • 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.

  • 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.

  • 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.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.