Article ID: 189902
Article Last Modified on 1/23/2007
APPLIES TO
- Microsoft Access 97 Standard Edition
This article was previously published under Q189902
Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
When you run a macro that uses the SetMenuItem to disable a custom menu option, the action fails.
RESOLUTION
To work around this behavior, you can use the SetMenuItem method from within a Visual Basic for Application procedure, as illustrated by the following line of code:
DoCmd.SetMenuItem 0,1,,acMenuGray
-or-
You can use the properties and methods of the CommandBars collection to manipulate and customize both built-in and custom menus.
For additional information about using Visual Basic for Applications to
modify command bars, please see the following article in the Microsoft Knowledge Base:
160293 ACC97: How to Dim Menu Items or Disable Toolbar Buttons in code
MORE INFORMATION
Steps to Reproduce Behavior
- Create a new database named MenuTest.mdb.
Create the following macro and save it as AddMenu:
Macro Name Action ------------------------------ AddMenu AddMenu Action Arguments ------------------------ Menu Name: Menu Menu Macro Name: Menu Status Bar Text:
Create the following macro and save it as Menu:
Macro Name Action ----------------------------- Beep Beep
Create the following macro and save it as GrayMenu:
Macro Name Action ---------------------------------- OpenForm SetMenuItem GrayMenu Action Arguments ------------------------- Form Name: Form1 View: Form Filter Name: Where Condition: Data Mode: Window Mode: Normal SetMenuItem Action Arguments ---------------------------- Menu Index: 0 Command Index: 0 Subcommand Index: Flag: Gray
- Create a new blank form in Design view and save it as Form1.
Set the MenuBar property of the form to AddMenu, and add the following command button to the detail section of the form:
Command Button: ----------------------- Name: CmdDimMenu Caption: Gray Menu Item OnClick: GrayMenu
- Open the form in form view, and click the command button.
Note that the menu item "Menu" is not disabled.
REFERENCES
For additional information about command bars, search for "CommandBars collection" using the Microsoft Access Help menu.
Additional query words: grayed unavailable dimmed greyed gray grey
Keywords: kbprb KB189902