ACC2: Sample DoMenuItem Access Basic Statements

ID: Q128425


The information in this article applies to:
  • Microsoft Access 2.0


SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

This article lists the Access Basic DoMenuItem action statements that you can use to activate menu items in the Form view menu bar and the Database window menu bar.


MORE INFORMATION

This article assumes that you are familiar with the DoMenuItem action and how it can be used in Access Basic. This article also assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Access Basic, please refer to the "Building Applications" manual.

NOTE: In the following examples, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when you re-create these examples.

Form View Menu Bar


File
   New
      Table
         DoCmd DoMenuItem A_FORMBAR, A_FILE, A_NEW,0, A_MENU_VER20

      Query
         DoCmd DoMenuItem A_FORMBAR, A_FILE, A_NEW,1, A_MENU_VER20

      Form
         DoCmd DoMenuItem A_FORMBAR, A_FILE, A_NEW,2, A_MENU_VER20

      Report
         DoCmd DoMenuItem A_FORMBAR, A_FILE, A_NEW,3, A_MENU_VER20

      Macro
         DoCmd DoMenuItem A_FORMBAR, A_FILE, A_NEW,4, A_MENU_VER20

      Module
         DoCmd DoMenuItem A_FORMBAR, A_FILE, A_NEW,5, A_MENU_VER20

   Close                         (see also Close action)
      DoCmd DoMenuItem A_FORMBAR, A_FILE, 1,, A_MENU_VER20

   Save Form            CTRL+S
      DoCmd DoMenuItem A_FORMBAR, A_FILE, A_SAVEFORM,, A_MENU_VER20

   Save Form As
      DoCmd DoMenuItem A_FORMBAR, A_FILE, A_SAVEFORMAS,, A_MENU_VER20

   Save Record          SHIFT+ENTER
      DoCmd DoMenuItem A_FORMBAR, A_FILE, A_SAVERECORD,, A_MENU_VER20

   Output To                 (see also OutputTo action)
      DoCmd DoMenuItem A_FORMBAR, A_FILE, 5,, A_MENU_VER20

   Print Setup
      DoCmd DoMenuItem A_FORMBAR, A_FILE, 6,, A_MENU_VER20

   Print Preview
      DoCmd DoMenuItem A_FORMBAR, A_FILE, 7,, A_MENU_VER20

   Print                CTRL+P   (see also Print action)
      DoCmd DoMenuItem A_FORMBAR, A_FILE, 8,, A_MENU_VER20

   Send
      DoCmd DoMenuItem A_FORMBAR, A_FILE, 9,, A_MENU_VER20

   Run Macro                     (see also RunMacro action)
      DoCmd DoMenuItem A_FORMBAR, A_FILE, 10,, A_MENU_VER20

   Add-ins
      NOT AVAILABLE

   Exit                          (see also Quit action)
      DoCmd DoMenuItem A_FORMBAR, A_FILE, 12,, A_MENU_VER20

Edit
   Undo Typing          CTRL+Z
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_UNDO,, A_MENU_VER20

   Undo Current Field / Undo Current Record  ESC
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_UNDOFIELD,, A_MENU_VER20

   Cut                  CTRL+X
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_CUT,, A_MENU_VER20

   Copy                 CTRL+C
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_COPY,, A_MENU_VER20

   Paste                CTRL+V
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_PASTE,, A_MENU_VER20

   Paste Special
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, 5,, A_MENU_VER20

   Paste Append
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, 6,, A_MENU_VER20

   Delete               DEL
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_DELETE_V2,, A_MENU_VER20

   Select Record
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD_V2,,_
      A_MENU_VER20

   Select All Records   CTRL+A
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTALLRECORDS_V2,,_
      A_MENU_VER20

   Find             CTRL+F      (see also FindRecord action)
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, 10,, A_MENU_VER20

   Replace          CTRL+H
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, 11,, A_MENU_VER20

   Insert Object
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, 12,, A_MENU_VER20

   Links
      DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, 13,, A_MENU_VER20

   Object
      Object Verb
         DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_OBJECT, A_OBJECTVERB,_
         A_MENU_VER20

View
   Form Design
      DoCmd DoMenuItem A_FORMBAR, 2, 0,, A_MENU_VER20

   Form
      DoCmd DoMenuItem A_FORMBAR, 2, 1,, A_MENU_VER20

   Datasheet
      DoCmd DoMenuItem A_FORMBAR, 2, 2,, A_MENU_VER20

   Subform Datasheet
      DoCmd DoMenuItem A_FORMBAR, 2, 3,, A_MENU_VER20

   Toolbars
      DoCmd DoMenuItem A_FORMBAR, 2, 4,, A_MENU_VER20

   Options
      DoCmd DoMenuItem A_FORMBAR, 2, 5,, A_MENU_VER20

Records
   DataEntry
      DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, ,, A_MENU_VER20

   Goto                          (see also GotoRecord action)

      First
         DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 1, 0, A_MENU_VER20

      Last
         DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 1, 1, A_MENU_VER20

      Next
         DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 1, 2, A_MENU_VER20

      Previous
         DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 1, 3, A_MENU_VER20

      New
         DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 1, 4, A_MENU_VER20

   Refresh
      DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, A_REFRESH,, A_MENU_VER20

   Quick Sort
      Ascending
         DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 3,0, A_MENU_VER20

      Descending
         DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 3,1, A_MENU_VER20

   Edit Filter/Sort
      DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 4,, A_MENU_VER20

   Apply Filter/Sort             (see also ApplyFilter action)
      DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 5,, A_MENU_VER20

   Show All Records              (see also ShowAllRecords action)
      DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 6,, A_MENU_VER20

   Allow Editing
      DoCmd DoMenuItem A_FORMBAR, A_RECORDSMENU, 7,, A_MENU_VER20

Window
   Tile
      DoCmd DoMenuItem A_FORMBAR, 4, 0,, A_MENU_VER20

   Cascade
      DoCmd DoMenuItem A_FORMBAR, 4, 1,, A_MENU_VER20

   Arrange Icons
      DoCmd DoMenuItem A_FORMBAR, 4, 2,, A_MENU_VER20

   Hide
      DoCmd DoMenuItem A_FORMBAR, 4, 3,, A_MENU_VER20

   Unhide
      DoCmd DoMenuItem A_FORMBAR, 4, 4,, A_MENU_VER20

   Size to Fit Form
      DoCmd DoMenuItem A_FORMBAR, 4, 5,, A_MENU_VER20

Help
   Contents
      DoCmd DoMenuItem A_FORMBAR, 5, 0,, A_MENU_VER20

   Search
      DoCmd DoMenuItem A_FORMBAR, 5, 1,, A_MENU_VER20

   Cue Cards
      DoCmd DoMenuItem A_FORMBAR, 5, 2,, A_MENU_VER20

   Technical Support
      DoCmd DoMenuItem A_FORMBAR, 5, 3,, A_MENU_VER20

   About Microsoft Access
      DoCmd DoMenuItem A_FORMBAR, 5, 4,, A_MENU_VER20 

Database Window Menu Bar

NOTE: Before you specify a DoMenuItem action, set the focus to the Database window. To do so, use the SelectObject action to select the default object in the list of available tables in the Database window with the following:

   DoCmd SelectObject A_TABLE, , True

File
   New Database CTRL+N
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 0,, A_MENU_VER20

   Open Database CTRL+O
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 1,, A_MENU_VER20

   Close Database
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 2,, A_MENU_VER20

   New
      Table
         DoCmd SelectObject A_TABLE, , True
         DoCmd DoMenuItem 1, A_FILE, 3, 0, A_MENU_VER20

      Query
         DoCmd SelectObject A_TABLE, , True
         DoCmd DoMenuItem 1, A_FILE, 3, 1, A_MENU_VER20

      Form
         DoCmd SelectObject A_TABLE, , True
         DoCmd DoMenuItem 1, A_FILE, 3, 2, A_MENU_VER20

      Report
         DoCmd SelectObject A_TABLE, , True
         DoCmd DoMenuItem 1, A_FILE, 3, 3, A_MENU_VER20

      Macro
         DoCmd SelectObject A_TABLE, , True
         DoCmd DoMenuItem 1, A_FILE, 3, 4, A_MENU_VER20

      Module
         DoCmd SelectObject A_TABLE, , True
         DoCmd DoMenuItem 1, A_FILE, 3, 5, A_MENU_VER20

   Rename                       (see also Rename action)
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 4,, A_MENU_VER20

   Output To                    (see also OutputTo action)
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 5,, A_MENU_VER20

   Import                       (see also Transfer actions)
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 6,, A_MENU_VER20

   Export                       (see also Transfer actions)
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 7,, A_MENU_VER20

   Attach Table                 (see also TransferDatabase action)
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 8,, A_MENU_VER20

   Imp/Exp Setup
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 9,, A_MENU_VER20

   Print Setup
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 10,, A_MENU_VER20

   Print Preview
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 11,, A_MENU_VER20

   Print    CTRL+P               (see also Print action)
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 12,, A_MENU_VER20

   Print Definition
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 13,, A_MENU_VER20

   Send
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 14,, A_MENU_VER20

   Run Macro                    (see also RunMacro action)
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 15,, A_MENU_VER20

   Add-ins
      NOT AVAILABLE

   Exit                          (see also Quit action)
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_FILE, 17,, A_MENU_VER20

Edit
   Undo
      NOT AVAILABLE

   Cut CTRL+X
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_EDITMENU, 1,, A_MENU_VER20

   Copy CTRL+C
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_EDITMENU, 2,, A_MENU_VER20

   Paste CTRL+V
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_EDITMENU, 3,, A_MENU_VER20

   Delete DEL
      DoCmd SelectObject A_TABLE, , True
     DoCmd DoMenuItem 1, A_EDITMENU, 4,, A_MENU_VER20

   Relationships
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, A_EDITMENU, 5,, A_MENU_VER20

Security
   Permissions
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, 3, 0,, A_MENU_VER20

   Users
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, 3, 1,, A_MENU_VER20

   Groups
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, 3, 2,, A_MENU_VER20

   Change Password
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, 3, 3,, A_MENU_VER20

   Change Owner
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, 3, 4,, A_MENU_VER20

   Print Security
      DoCmd SelectObject A_TABLE, , True
      DoCmd DoMenuItem 1, 3, 5,, A_MENU_VER20 


REFERENCES

For more information about the DoMenuItem action, search for "DoMenuItem," and then "DoMenuItem Action" using the Microsoft Access 2.0 Help menu.

Keywords : kbusage FmsHowto
Version : 2.0
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: April 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.