Problem with Popup menus in Access

B

bpearson

I have a query about displaying a popup custom menu bar in Access 2003.
Well, by query what I mean is that I can't get it to work ...


I have created the new CommandBar to drop down off the main menu. [It's
effectively a popup menu plus cascading sub-menus to open most of the
screens within the application.] This all works fine.

I then want to display the same menu as a popup from various other
places within the app. This just doesn't seem to want to work at all.

My code is effectively as follows ...

Dim MyCmdBar as CommandBar

Set MyCmdBar = CommandBars("My main
cmdbar").Controls("&Screens").CommandBar.Controls("Other screens
....").CommandBar

MyCmdBar.ShowPopup

When I call this code from a command button on a form, I get the error
message "Method 'ShowPopup' of Object 'CommandBar' failed".

However if I insert the line

MsgBox Str$(MyCmdBar.type=msoBarTypePopup)

in my code it displays the answer 'True', which suggests to me that it
is (a) a valid CommandBar object and (b) it is of a type which supports
the ShowPopup method.


Any ideas?



Brian Pearson
Mace Limited
London
 
A

Albert D.Kallal

You can't use the showpopup if it is a standard menu (which you got, and we
KNOW this by you having explain that you got a main menu, and you can view
your menu from that - that being the case, then this is NOT a popup.

You can go:

MyCmdBar.Visiable = True.

If you need both he menu, AND ALSO that same menu as a popup, then you have
to make a new menu bar, copy all of the options from that old menu, and THEN
change the type of new menu to a popup (highlight the menu in the toolbars
tab while customizing, then hit the properties button - change the menu type
a "popup". You can a VERY nice warning message about how this menu is now in
the shortcut menu bar.

You should then be able to go:

MyCmdBar.ShowPopup

By the way, you can also just set that new short cut menu in the forms
"other" properties (set Shortcutmenu = yes, and set Shortcut menu to this
new shortcut - note how ONLY popup menus show for your selection - when
done, a right mouse click will show the menu (at the mouse cursor position I
might add). You can also leave that form stuff blank, and use the ShowPopup
method in code as you have....

Do note, that since you have to make a NEW menu bar, and THEN change your
refercne to that new shortcut, then your ref will be:

Set MyCmdBar = CommandBars("MyNewMenuName")
or, just use

CommandBars("MyNewMenuName").ShowPopUp

Remember, a right click, or shotcut menu can have sub-menus etc....but these
showpopup menus must be created as their OWN menu bar, and then changed to a
popup (after you do this, you can still add, or modify the menu, but you
will have to navagate to the shortcut menu bar while in customoze mode to
GET to the menu to be able to modify it).

So, those shortcut menus are a separate thing, and they reside in the
"special" short cut menus menu.
 
B

bpearson

Albert

Thanks for your reply. I must say I hadn't realised there were separate
classes of popup menu, those attached to menubars and freestanding
ones: I thought there was just a single (msoBarTypePopup) type.

It does seem very wasteful of resources to have to duplicate an entire
menu structure (in this case approaching 200 items) just to make the
menu appear in two different circumstances.

I guess though that this is what I'll have to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top