Table of contents
TOC
折叠目录
展开目录

DoCmd.SetMenuItem 方法 (访问)DoCmd.SetMenuItem Method (Access)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

在 Visual Basic 中 SetMenuItem 操作执行SetMenuItem方法。The SetMenuItem method carries out the SetMenuItem action in Visual Basic.

语法Syntax

表达式SetMenuItem(* * MenuIndex,* * CommandIndex,* * SubcommandIndex,* *标志)expression. SetMenuItem( ** MenuIndex, ** CommandIndex, ** SubcommandIndex, ** Flag )

表达式_一个表示DoCmd对象的变量。_expression A variable that represents a DoCmd object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data Type说明Description
MenuIndexMenuIndex必需RequiredVariantVariant一个整数,范围为从 0,这样有效的索引上的自定义菜单栏或全局菜单栏的活动窗口中的菜单在自定义菜单栏或全局菜单栏的菜单栏宏。如果选择该参数菜单和在 commandindex 和 subcommandindex 参数为空 (或将它们设置为 ?1),您可以启用或禁用该菜单名称。但是,您无法选中或取消选中菜单名称 (Microsoft Access 忽略标志参数对于菜单名称的acMenuCheckacMenuUncheck设置)。An integer, counting from 0, that's the valid index of a menu on the custom menu bar or global menu bar for the active window, as defined in the menu bar macro for the custom menu bar or global menu bar. If you select a menu with this argument and leave the commandindex and subcommandindex arguments blank (or set them to ?1), you can enable or disable the menu name itself. You can't, however, check or uncheck a menu name (Microsoft Access ignores the acMenuCheck and acMenuUncheck settings for the flag argument for menu names).
CommandIndexCommandIndex可选OptionalVariantVariant一个整数,范围为从 0,表示由 menuindex 参数,选择菜单上的命令的有效索引定义的自定义菜单栏或全局菜单栏的活动窗口选定的菜单的宏组中定义。An integer, counting from 0, that's the valid index of a command on the menu selected by the menuindex argument, as defined in the macro group that defines the selected menu for the custom menu bar or global menu bar for the active window.
SubcommandIndexSubcommandIndex可选OptionalVariantVariant一个整数,范围为从 0,这样子由 commandindex 参数,选择的子菜单中的有效索引定义的自定义菜单栏或全局菜单栏的活动窗口所选子菜单的宏组中定义。An integer, counting from 0, that's the valid index of a subcommand in the submenu selected by the commandindex argument, as defined in the macro group that defines the selected submenu for the custom menu bar or global menu bar for the active window.
标志Flag可选OptionalVariantVariant命令或子命令要设置成的状态。可为以下常量之一。The state you want to set the command or subcommand to. Can be one of the following constants.
  • acMenuCheckacMenuCheck

  • acMenuGrayacMenuGray

  • acMenuUncheckacMenuUncheck

  • acMenuUngray (默认值)acMenuUngray (default)

注解Remarks

您可以使用SetMenuItem方法设置的状态 (启用或禁用,选中或取消选中) 的菜单项的自定义菜单栏或全局菜单栏的活动窗口上。You can use the SetMenuItem method to set the state of menu items (enabled or disabled, checked or unchecked) on the custom menu bar or global menu bar for the active window.

请注意SetMenuItem方法仅适用于自定义菜单栏和全局菜单栏使用菜单栏宏创建的。在此版本的 Microsoft Access 只对与 Microsoft Access 97 以前版本的兼容性包含SetMenuItem方法。它不能用新的命令栏功能。Note The SetMenuItem method works only with custom menu bars and global menu bars created by using menu bar macros. The SetMenuItem method is included in this version of Microsoft Access only for compatibility with versions prior to Microsoft Access 97. It doesn't work with the new command bars functionality.

另请参阅See also

概念Concepts

DoCmd 对象DoCmd Object

© 2018 Microsoft