DoCmd.DoMenuItem (Access)
Displays the appropriate menu or toolbar command for Microsoft Access.
DoMenuItem (MenuBar, MenuName, Command, Subcommand, Version)
Dim lngMenuBar As Long: lngMenuBar =
Dim strMenuName As String: strMenuName =
Dim lngCommand As Long: lngCommand =
DoCmd.DoMenuItem MenuBar:=lngMenuBar, MenuName:=strMenuName, Command:=lngCommand
Arguments
The following arguments are required:
MenuBar (Long) - Use the intrinsic constant acFormBar for the menu bar in Form view. For other views, use the number of the view in the MenuBar argument list, as shown in the Macro window in previous versions of Microsoft Access (count down the list, starting from 0).
MenuName (Long) - You can use one of the following intrinsic constants: acFile acEditMenu acRecordsMenu You can use acRecordsMenu only for the Form view menu bar in Access version 2.0 and Access 95 databases. For other menus, use the number of the menu in the MenuName argument list, as shown in the Macro window in previous versions of Access (count down the list, starting from 0).
Command (Long) - You can use one of the following intrinsic constants: acNew acSaveForm acSaveFormAs acSaveRecord acUndo acCut acCopy acPaste acDelete acSelectRecord acSelectAllRecords acObjectRefresh For other commands, use the number of the command in the Command argument list, as shown in the Macro window in previous versions of Access (count down the list, starting from 0).
Optional arguments
The following arguments are optional
Subcommand (Long) - You can use one of the following intrinsic constants: acObjectVerb acObjectUpdate The acObjectVerb constant represents the first command on the submenu of the Object command on the Edit menu. The type of object determines the first command on the submenu. For example, this command is Edit for a Paintbrush object that can be edited. For other commands on submenus, use the number of the subcommand in the Subcommand argument list, as shown in the Macro window in previous versions of Access (count down the list, starting from 0).
Version (Long) - Use the intrinsic constant acMenuVer70 for code written for Access 95 databases, the intrinsic constant acMenuVer20 for code written for Access version 2.0 databases, and the intrinsic constant acMenuVer1X for code written for Access version 1.x databases. This argument is available only in Visual Basic. NOTE: The default for this argument is acMenuVer1X, so that any code written for Access version 1.x databases will run unchanged. If you are writing code for a Access 95 or version 2.0 database and want to use the Access 95 or version 2.0 menu commands with the DoMenuItem method, you must set this argument to acMenuVer70 or acMenuVer20. Also, when you are counting down the lists for the MenuBar, MenuName, Command, and Subcommand action arguments in the Macro window to get the numbers to use for the arguments in the DoMenuItem method, you must use the Access 95 lists if the Version argument is acMenuVer70, the Access version 2.0 lists if the Version argument is Version, and the Access version 1.x lists if Version is acMenuVer1X (or blank). NOTE: There is no acMenuVer80 setting for this argument. You can't use the DoMenuItem method to display Access commands (although existing DoMenuItem methods in Visual Basic code will still work). Use the RunCommand method instead.