SetMenuItem

MartijnAn

Registered User.
Local time
Today, 09:07
Joined
Sep 30, 2004
Messages
51
SetMenuItem

--------------------------------------------------------------------------------

Hi All,

I have an issue which does not come to an end and it is making me crazy!
In an form_load event I have the following code:

Private Sub Form_Load()
DoCmd.SetMenuItem 1, 1, , acMenuGray
End Sub

Well, I do no not receive any error, but the specific item does not turn grey! Can someone tell me what I do wrong?

Thanks.

M.
 
Hi,

The Access 2000 help says:
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. In Microsoft Access 2000, you must use the properties and methods of the CommandBars collection object to enable or disable top level menu items.

Maybe you should be using the CommandBars collection?

Thanks,
Keith.
 
From Access help:

Remarks
The SetMenuItem action works only on a custom menu bar or global menu bar for the active window. If the active window doesn't have a custom menu bar or global menu bar, running a macro containing the SetMenuItem action causes a run-time error. Note that a global menu bar, if you've defined one, replaces the built-in menu bar for all Access windows, except where you've added a custom menu bar for a form or report.

You can use this action to set the state of menu commands and subcommands, but not subcommands of subcommands.


Does any of that answer your question? Are you using it on a custom menu bar?
 
I solved it with the commandbar method, the only problem is that I have to enable everything each time I leave the form...

@tpkstock: Yes, I built my own custom menu's. The funny thing is that a get no longer a run-time error, but he does not disable the menuitems that I selected. I tried various possible solutions btw (1,2) (2,1) etc.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom