Pete Danes
Pete Danes

Reputation: 289

Access custom right-click menus

I have written an app that makes extensive use of custom right-click menus on an Access form. The code works great and the user loves it, but lately I am having trouble making it work properly.

In earlier versions of Access it worked well, but newer version seem much more limited in how many items can be put in such menus. The documentation is silent on the matter, and nobody in any newsgroup has had any useful ideas, but I regularly get random error about stack space, out of memory, and general lockups when populating the menus. Doing a C&R used to help, but now even that is not enough, and some menus I can no longer populate at all.

I tried building an app that just built menus until it crashed, to get some idea of what the limits may be, and I am well below what that indicated, but the experimental app had nothing else, while the real app has a great deal else.

Is there any information on how much stuff can be put into these menus, and what the menus share space with? There may be something I can do another way to make more room for the menus. I tried moving all code out of the form, leaving only event stubs that called routines in standard code modules, but that did not help.

And how are they stored/activated? The app is MUCH slower to load when it has these menus, even though no code is running on start-up.

********** Edited to add this:

I use VBA to create a menu, like this:

Application.CommandBars.Add "RCStat", msoBarPopup, False, False

then add it to a control. like this:

Application.CommandBars.cboStat.ShortcutMenuBar = "RCStat"

I add controls (only popups and buttons) like this:

Application.CommandBars.Controls.Add(type:=msoControlPopup)
Application.CommandBars.Controls.Add(type:=msoControlButton, Parameter:="StatKod = 77")

It runs perfectly and the menu items work exactly as expected, except that it bombs after adding some number of controls. It doesn't seem to matter where I add them, just the total number of added controls hits some undefined threshold, and the app crashes.

I got the original code from Getz, Litwin and Gilbert, 2000 edition. Back then, it worked great. But as the versions advance and the app accumulates data, it is becoming less and less functional. However, there are only around 10,000 records, and the app itself is less than 100MB - nowhere close to any of Access's upper size limits.

Upvotes: 2

Views: 1864

Answers (2)

dbWizard
dbWizard

Reputation: 132

Pete, I've done quite a bit of work with shortcut menus, and created the Access Shortcut Tool about 5 years ago, but have never attempted a menu with so many controls although some have 3 or 4 levels.

I am not aware of any restrictions on the number of elements in the commandbars collection, but I find that shortcut menus with too many options, like lists and combo boxes with too many items, are difficult for users to navigate. I generally break these up into segments and use buttons in the form header to display the appropriate menu. Sorry I'm unable to provide anything more helpful.

Dale

Upvotes: 2

LukeChung-FMS
LukeChung-FMS

Reputation: 119

We have a commercial product, Total Access Components, that includes as one of its 30 components a right click popup menu that can include icons and font styles.

Here's the info for the popup menu control: https://fmsinc.com/MicrosoftAccess/controls/components/popup-menu/

There's a free trial if you want to try it.

Upvotes: 0

Related Questions