Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Posted on 1998-10-10
4
19,480 Views
Last Modified: 2012-05-04
If I were to come across the following line of code in Access 97, how would I know EXACTLY what this command does?

  DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

The online help is pretty poor.  Searching the .HLP file on "acEditMenu" or "acMenuVer70" doesn't provide much (if any) in depth detail explanation.

How do I know what this code does?
0
Comment
Question by:Monroe406
  • 2
4 Comments
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1964958
From the Microsoft Office 97 Visual Basic Reference, Volume 1.



DoMenuItem Method
Applies To

DoCmd object.

Description

The DoMenuItem method carries out the DoMenuItem action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

Note In Microsoft Access 97, the DoMenuItem method has been replaced by the RunCommand method. The DoMenuItem method is included in this version of Microsoft Access only for compatibility with previous versions. When you run existing Visual Basic code containing a DoMenuItem method, Microsoft Access will display the appropriate menu or toolbar command for Microsoft Access 97. However, unlike the DoMenuItem action in a macro, a DoMenuItem method in Visual Basic code isn't converted to a RunCommand method when you convert a database created in a previous version of Microsoft Access.

Some commands from previous versions of Microsoft Access aren't available in Microsoft Access 97, and DoMenuItem methods that run these commands will cause an error when they're executed in Visual Basic. You must edit your Visual Basic code to replace or delete occurrences of such DoMenuItem methods.

Syntax

DoCmd.DoMenuItem menubar, menuname, command[, subcommand][, version]

The DoMenuItem method has the following arguments.

Argument
 Description
 

 
menubar
 Use the intrinsic constant acFormBar for the menu bar in Form view.
 

 For other views, use the number of the view in the Menu Bar argument list, as shown in the Macro window in previous versions of Microsoft Access (count down the list, starting from 0).
 
menuname
 You can use one of the following intrinsic constants:
 

 acFile
acEditMenu
acRecordsMenu
 

 You can use acRecordsMenu only for the Form view menu bar in Microsoft Access version 2.0 and Microsoft Access 95 databases.
 

 For other menus, use the number of the menu in the Menu Name argument list, as shown in the Macro window in previous versions of Microsoft Access (count down the list, starting from 0).
 
command
 You can use one of the following intrinsic constants:
 

 acNew
acSaveForm
acSaveFormAs
acSaveRecord
acUndo
acCut
acCopy
acPaste
acDelete
acSelectRecord
acSelectAllRecords
acObject
acRefresh
 

 For other commands, use the number of the command in the Command argument list, as shown in the Macro window in previous versions of Microsoft Access (count down the list, starting from 0).
 




(continued)

subcommand
 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 Microsoft Access (count down the list, starting from 0).
 
version
 Use the intrinsic constant acMenuVer70 for code written for Microsoft Access 95 databases, the intrinsic constant acMenuVer20 for code written for Microsoft Access version 2.0 databases, and the intrinsic constant acMenuVer1X for code written for Microsoft 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 Microsoft Access version 1.x databases will run unchanged. If you're writing code for a Microsoft Access 95 or version 2.0 database and want to use the Microsoft 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 Menu Bar, Menu Name, 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 Microsoft Access 95 lists if the version argument is acMenuVer70, the Microsoft Access version 2.0 lists if the version argument is acMenuVer20, and the Microsoft 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 Microsoft Access 97 commands (although existing DoMenuItem methods in Visual Basic code will still work). Use the RunCommand method instead.
 




Remarks

The selections in the lists for the Menu Name, Command, and Subcommand action arguments in the Macro window depend on what you've selected for the previous arguments. You must use numbers or intrinsic constants that are appropriate for each menubar, menuname, command, and subcommand argument.

If you leave the subcommand argument blank but specify the version argument, you must include the subcommand argument's comma. If you leave the subcommand and version arguments blank, don't use a comma following the command argument.

See Also

AddMenu action, DoCmd object, DoMenuItem action, RunCommand method, SendKeys statement.

Example

The following example uses the DoMenuItem method to carry out the Paste command on the Edit menu in Form view in a Microsoft Access 95 database:

DoCmd.DoMenuItem acFormBar, acEditMenu, acPaste, , acMenuVer70
The next example carries out the Tile command on the Window menu in Form view in a Microsoft Access version 2.0 database:

DoCmd.DoMenuItem acFormBar, 4, 0, , acMenuVer20


This is also in better format at Microsoft:

http://premium.microsoft.com/msdn/library/officedev/office/output/f1/d2/s5a0d9.htm
http://premium.microsoft.com/msdn/library/officedev/access/d1/s11690.htm

Basically, you just count from zero to the menu item.  It looks like it pastes from the clipboard and appends to the current item.  It depends on what the active object is at at the time the method is executed.  

Later,
Martin
0
 

Author Comment

by:Monroe406
ID: 1964959
Thanks, but 99% of what you provided was pasted from the Access help file which I had read and originally described as "pretty poor".

 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Looking at the above example, the number "6", what does it represent?  Does it represent the sixth ACTIVE (enabled) line in the Edit menu, or does it represent the 6th line in the Edit menu regardless of a line's enabled or disabled status?  Do separators in menus count?  IOW,

Undo (enabled)
Redo (disabled)
------
Select (disabled)
Select all  (disabled)
------
Copy  (disabled)
Paste  (disabled)
Cut (disabled)
------
Find (enabled)
Find Again (enabled)

.with the above menu, what would "3" in ...

 DoCmd.DoMenuItem acFormBar, acEditMenu, 3, , acMenuVer70

.represent?  Would it represent the "------" divider (the 3rd physical line), or would it represent "Select" (3rd line with text) or would it represent "Find Again" (the 3rd ENABLED line)?  This is what I was trying to get at in my question.


0
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1964960
You are right, I didn't know if you had those docs or not.  I'm not for sure, you would think a value of '3' would fail.  I haven't tested it, so who knows.  All I can suggest is trying it out and see what happens.

Sorry I can't help more,
Martin

0
 
LVL 4

Accepted Solution

by:
tomook earned 50 total points
ID: 1964961
In your example, 3 is Select and 6 is Paste. You count all the items, enabled or not. If you execute a DoCmd.DoMenuItem while the menu command is disabled, you will get an error. The argument acMenuVer70 means you have to look in Access 95 (version 7) to be sure. I recommend replacing this code with DoCmd.RunCommand. In this case, Edit->Paste is:
DoCmd.RunCommand acCmdPaste

Edit->Select depends on the context:
DoCmd.RunCommand acCmdSelectForm
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSelectReport
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question