Repeated rebuild of right-click menu throws error (1 Viewer)

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
Just a brief note - I made an empty database with a single form and a textbox, to which I added RC controls in code. It just crashed, with 15,626 controls added. The textbox works. Takes several seconds, but that RC menu pops up and I can scroll through the controls.
 

isladogs

MVP / VIP
Local time
Today, 23:38
Joined
Jan 14, 2017
Messages
18,212
Just a brief note - I made an empty database with a single form and a textbox, to which I added RC controls in code. It just crashed, with 15,626 controls added. The textbox works. Takes several seconds, but that RC menu pops up and I can scroll through the controls.

Sorry but can you clarify what that means and possibly post it here.
Forms have a limit in the number of controls over the form lifetime.
IIRC that limit is 768 or thereabouts. So clearly you don't mean form controls. What do you mean?
 

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
Sorry but can you clarify what that means and possibly post it here.
Forms have a limit in the number of controls over the form lifetime.
IIRC that limit is 768 or thereabouts. So clearly you don't mean form controls. What do you mean?

That is the terminology used by Microsoft. Adding an item to an RC menu is called adding a control. In my original post, I quoted this line as the one that crashed:

Set AEp = .Controls.Add(msoControlPopup)

I executed that 15,626 times in my new test database before it crashed, and all those 15,626 items are in fact available via a right-click on the textbox to which I added all these 'controls'. Clearly, those are not the same controls as the normal controls that are placed on a form, like textboxes, comboboxes, labels and the like.
 

isladogs

MVP / VIP
Local time
Today, 23:38
Joined
Jan 14, 2017
Messages
18,212
Just tried to look at your files from post #17.
I joined them to create the 6MB original using PineTools site but get an error that its not a valid archive



So I'm stuck unless you can shrink it further. Or possibly split the full zip file using Winzip if you have that
Did you remove all irrelevant items and most of the data from the file?
Did you compact before zipping?

As I said in my last reply, are you able to upload your test database?
 

Attachments

  • Capture.PNG
    Capture.PNG
    15.3 KB · Views: 445

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
Just tried to look at your files from post #17.
I joined them to create the 6MB original using PineTools site but get an error that its not a valid archive



So I'm stuck unless you can shrink it further. Or possibly split the full zip file using Winzip if you have that
Did you remove all irrelevant items and most of the data from the file?
Did you compact before zipping?

As I said in my last reply, are you able to upload your test database?

Check the instructions I wrote again - you have to UNZIP the individual pieces FIRST, then join the unzipped pieces, using that website, into a zipped total file, then unzip that to get the final .accdb file. Just tried it and it works fine, but you cannot join the the four zipped attachments directly.

And here is the test DB. It's a very simple construct - one form, with one textbox, and a simple routine that links an RC menu to that textbox and then adds controls until it crashes. On my machine it ran to 15,626, although it took a while.

Open the form in design view or run view - it doesn't matter. You can step through the code and try it every so often, and you will see the RC menu items being added, or you can just let it run for a bit. I've put a DoEvents into the loop, so you can stop it any time you want and see how it's doing.
 

Attachments

  • RCTester.accdb
    928 KB · Views: 122

isladogs

MVP / VIP
Local time
Today, 23:38
Joined
Jan 14, 2017
Messages
18,212
Sorry about that.
I've successfully unzipped the lichen file but keep getting error messages.
Due to the language issue, I don't know what its saying.
I haven't looked at the code yet ...but have seen your 4 level right click menu.
It does seem very clever and understand why you want to fix it rather than try something else
Again due to language issue why do you have a date value on the form where you right click to get the entire set of values in a 'treeview' structure?
And would a treeview be another possibility?

In the meantime, I'm just running your test build now - have slightly modified the code to debug.print every 50 loops in order to speed things up slightly. Currently at 8250 but is now extremely slow. Is it using up available connections? I have an app to check that but will first let it run till it crashes

What is the exact error you get when it crashes? (I suppose I'll find out myself eventually but I want to post this shortly before I sign off for tonight)

In advance of knowing the error, I'm just wondering whether any registry changes would help
e.g. increase maxlocksperfile / maxbuffersize
See e.g. https://www.access-programmers.co.uk/forums/showthread.php?t=298749

UPDATE:
Just returned and it crashed but earlier than yours:



Same error as yours?
 

Attachments

  • Capture.PNG
    Capture.PNG
    4.8 KB · Views: 395
Last edited:

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
Sorry about that.
I've successfully unzipped the lichen file but keep getting error messages.
Due to the language issue, I don't know what its saying.
I haven't looked at the code yet ...but have seen your 4 level right click menu.
It does seem very clever and understand why you want to fix it rather than try something else

In the meantime, I'm just running your test build now - have slightly modified the code to debug.print every 50 loops in order to speed things up slightly. Currently at 8250 but is now extremely slow. Is it using up available connections? I have an app to check that but will first let it run till it crashes

What is the exact error you get when it crashes? (I suppose I'll find out myself eventually but I want to post this shortly before I sign off for tonight)

In advance of knowing the error, I'm just wondering whether any registry changes would help
e.g. increase maxlocksperfile / maxbuffersize
See e.g. https://www.access-programmers.co.uk/forums/showthread.php?t=298749

UPDATE:
Just returned and it crashed but earlier than yours:



Same error as yours?

Yes, that is the same error - add method failed. I'm not all that surprised that the number is different. It's probably not a well-defined limit, like the number of controls per form, so it's probably just running out of resources somewhere. I'm running Access Professionl Plus 2010 on a 64-bit Win 7 ThinkPad - YMMV.

If you post a screenshot of the Czech error message, I'll tell you what it says. Not sure why you'd be getting a Czech error message - it must have detected something internal, otherwise error messages should be in the language of the computer it's running on.

The process does slow down as the number of controls increases. I don't know why. I don't think it should have anything to do with connection pooling - it's not writing to a normal data table, but I don't know for certain. I also ran into something weird last night - the menu is not saved when the form is saved. In my real database, all such changes do get saved, but not in the test one, even when I make a point of explicitly saving the form. I can close the form, reset the DB in the VBA window and everything continues to work, but when I close the DB and re-open it, the RC menu is gone. And it's not just disconnected, it doesn't exist. When I execute this line:

Set cbRoot = Application.CommandBars.Add("RCTestMenu", msoBarPopup, False, True)

the menu appears instantly, attached to the textbox, but it's empty, until I continue with the code, adding controls again.

Again due to language issue why do you have a date value on the form where you right click to get the entire set of values in a 'treeview' structure?
And would a treeview be another possibility?

Sorry, I don't understand the question. You see how it works - the multi-level structure is to keep the available choices on the screen, instead of having to scroll through a long list of choices. Scrolling and clicking are both something I'm trying to avoid - the mouse-over is enough to expand and contract the choices. Both are annoying and take time, and fussy for precision in the case of scrolling a long RC menu.

Why I have a date value on the form - the user needed it. It's spread over three textboxes, because there are incomplete dates in the data - year and month, or only year. If it contained only real dates, I would have used a single textbox. The reason I have the values in the RC menu is so that the user can quickly select a date that actually exists in the data and filter the dataset for that date. I don't want to put a date selector control there, because there are many real dates that do not exist in the data. Picking through many non-existent dates to get the few that do exist is not how I want this to operate. The RC menu not only filters, but by its very existence shows whether a specific date even exists in the data, with having to go looking - filter the data and see that the result set is empty. That's slower and unnecessary effort for the user, when simply mousing over the RC menu shows you that information.

A treeview could also be made to work, but again, it would be another control on the form, which is what the RC menu avoids. A separate control not only takes up space, but looks similar to a place where data is entered. The RC menu is completely invisible until it's needed.
 
Last edited:

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
Just ran it again, with 10 textboxes using the same RC menu. This time it made it to 15,916 controls added before crashing, so it seems that it's not some hard-coded limit in Access - just running off the deep end, past what the designers ever thought might happen,or maybe didn't even think about it at all. It's slow to appear with that many items, and is always slow, even after repeated activations. Apparently it's not getting cached in any manner.

My next step will be to make 10 different menus - this last run used the same menu for all ten textboxes.

After that, I will start experimenting with various stages of cascading menus.
 

isladogs

MVP / VIP
Local time
Today, 23:38
Joined
Jan 14, 2017
Messages
18,212
Just out of interest roughly how long does that take to reach the limit? On my PC it took over an hour to reach 10000 or so.

As previously mentioned, I would try a few other things first as its clearly running out of 'resources'
1. Check available connections. See http://www.mendipdatasystems.co.uk/available-connections/4594418530
2. Modify registry settings to increase maxlocksperfile and maxbuffersize values.
All of those are easy to do and may help or at least eliminate an area to investigate.

I will attach the Czech message later today. Its an automation error IIRC
 

isladogs

MVP / VIP
Local time
Today, 23:38
Joined
Jan 14, 2017
Messages
18,212
The attached automation error message appears when I open the application.
It also appears after using either of the two right click menus which prevents the Datum or Prir Celky item being updated

In addition, if I instead use the dropdown to select the Prir Celky item, there is a brief appearance of a blue box with text and a blank green rectangle. It then disappears almost immediately. If that's not intentional, I'll pause the code later and get a screenshot.
You have 6 code events on that combo. Could that be rationalised into fewer events to prevent possible conflicts

For info I also get a Czech message when I click on the Fotogalerie button but I think that's intentional
 

Attachments

  • Capture1.PNG
    Capture1.PNG
    7.5 KB · Views: 117

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
Not very long - a few minutes. Just ran my setup with 10 textboxes with each having its own RC menu, and it crashed at 1,214 - roughly a tenth of how far it got with only one textbox or one menu on ten textboxes. It was also faster to execute, but that may be partly because I have only one DoEvents statement per loop, and each loop iteration does all ten textboxes. All ten textboxes have their own independent menu this time, and the menus, with the 1,214 items appear almost instantly on a right mouse-click - much faster than the 15,000+ menus.

I'll try the settings mods later - right now I need to scram to get something prepped for work tomorrow. My next test setup will be with cascaded RC menus. I want to see how deep I can cascade them first, then try various configurations of how many can be on each level, how many total and the like. Those are a little more complicated to code, so it will be a bit, but I'll post the results here as I generate them.
 

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
That message is when the database detects something internal. It's just a warning from my error-handling routine that an unexpected error occurred, and the behavior may become erratic, so it would be better to close and re-open the database. The user of this app is a somewhat fractured scientist, and has little patience with computers. I have to make some stuff extremely obnoxious to force her to acknowledge or deal with certain issues, hence the vicious red background after the error message. That's too much for her to look at, so she follows instructions to close and reopen, and sends me what she was doing at the time so I can track it down and fix it. What the invalid OLEVERB is I have no idea. Maybe you need to reload some code libraries to match your local ones. Try the VBA Tools / References dialog to see if there is something missing there. In any case, most of the app should continue to function even after this message - at least enough of it for you to see the menus in operation.

The blue background is a 'Please wait' indicator for menus that take a while to rebuild. The Prir Celky menu rebuilds quickly, so I don't really need it there, but this is still a development version. The delivered version will have that message only for the slow ones, or maybe none, if I manage to get this sorted and operational the way I'd like.

Yes, the FotoGalerie will not work for you. The database has an associated folder structure of lichen photographs, many thousands of them, and this dialog loads all pictures of the same genus and species as the one on the current record. You don't have those pictures, so that won't work for you.
 

isladogs

MVP / VIP
Local time
Today, 23:38
Joined
Jan 14, 2017
Messages
18,212
The first thing I always do when I try any downloaded database is check the references (all present) and whether it compiles (it does). I am using A2010 32-bit - same as you

That red background is rather unpleasant but that's all I ever see.
I've never seen it look like the screenshot you uploaded in #15.

As I said the error message occurs each time I start your app & after using either of your RC menus. It also occurs when I click the filter button to the right of the Datum field.

Also if I click any other button to open another popup form, I get error messages when I try to close them again. Two examples attached. I think all messages are the same or very similar.

So I'm afraid this is just about unuseable for me. That together with your test database being incredibly slow for me means I don't think I can do any further testing on either of these apps.

However do let me know whether any of my suggestions helped

BTW - had a quick look at some of your code though not in detail - some great names for several procedures: e.g. Muddle / Twidge ;)
 

Attachments

  • Capture2.jpg
    Capture2.jpg
    96.6 KB · Views: 112
  • Capture3.jpg
    Capture3.jpg
    97.7 KB · Views: 110

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
Yeah, I understand - wading through never-ending error messages is a monumental pain in the fundament. I'm not sure why it's misbehaving like that, although I suspect it's a language problem - it works flawlessly on all machines here, but they are all running a Czech OS and Czech Office package. The non-Latin characters used in the Czech language have a tendency to wreak havoc in English-only machines. It also may be something in the ribbon - that is full of Czech characters, and sometimes XML parsers are very fussy about that.

The red background is obnoxious on purpose - if I leave it tolerable, the user has a tendency to keep on using it, even after it throws an error, which can be bad. It may have lost some global references, which may mess up displayed results - it could show some results, but maybe the wrong ones, since a global variable may have been reset, or a class reference cleared and re-initialized, without the display properly reflecting the current status. You know how it is when code wanders off on its own - no telling what condition it's in, or what it's likely to do. This is irritating enough to keep her from doing that.

The proc names are for my entertainment, when developing. Easy to find and identify when testing. I dress it up before shipping, though.

In any case, I think I have a plan of action. I'm going to run a few more tests for various limits, but mostly just to get a general idea of what I can get away with. I'll post the limits here as I encounter them, just to keep the information in one place, in case someone else runs across this and is curious. I'll take a look at tweaking some of the settings you mentioned, but I don't want to go into that as a permanent strategy - I want this to work, in any standard configuration it's likely to be run on, without having to tweak obscure settings in every machine, especially since such tweaks may have an unintended impact on something else.

The limits I've run into so far are plenty generous enough for my needs anyway; I don't really need to push them back any more. I will have around 5,000 total RC menu items on the entire form, if I activate absolutely every RC menu that I would like to, so I'm nowhere near any of the limits I've hit so far.

As for the crashing on rebuild, I think that will be fixed by not doing complete rebuilds, which are actually not necessary anyway. I will automatically populate the menus initially, when a new version is delivered, and do a C & R afterwards. I have code in there so that when I have a new version to deliver, I can send the user an empty database with all the new code in it. She runs that, and it looks around at itself and its surroundings. When it sees that it has no data in its own tables, it pops up a dialog asking for where to import the current data from. The user points the dialog to her current database, and this code reads everything in from there, checking sums and doing adjustments as necessary, if the table structure has changed in the new version. Once all records have been read in, and the totals read in correspond to the totals in the old database, the old database is closed, renamed to an archive name, with date included, the new database writes out a script that will rename it and restart it under the new name, then delete itself. The new database sets the C & R on close flag, then closes itself. The script watches for the database to close, then starts its work. When the new database reopens under the standard name, it clears the C & R flag, and the user is ready to go again, all her current data imported into the new version. I've been using this method for years, on a number of apps, and it works extremely well - users do not have to stop their work, ship me their data to import or anything of the sort. I set up everything to work with whatever new functions or repairs are necessary, while the users continue to do their normal work in the app. When I ship the new one, all they need to do is copy the new, empty database into the proper folder and start it - everything else is automatic. It even knows the default import database name, so when the file import dialog opens, usually all they have to do is hit Enter once.

So I will add code to rebuild the RC menus after this initial import. After that, in normal use, I will only add or delete the controls necessary, and only IF necessary - if an aux table value changes, for instance, it may be enough to just change the caption on the control. If the value changes enough to require a repositioning of the control (alphabetical order, mostly), I will delete just that one control and add a new one in the proper place. I will add a global counter for every control deleted or added, probably stored in a custom document variable, and when that reaches some reasonable number, maybe 100, maybe 1000 – whatever my additional testing seems to indicate, I will again set the C & R on close flag.

That seems to me should give me the functionality I want, boost the speed considerably and eliminate the error caused by too many adds, all at the same time.
 

isladogs

MVP / VIP
Local time
Today, 23:38
Joined
Jan 14, 2017
Messages
18,212
OK good luck. Hope you fix it.
I do recommend you try checking the available connections whilst running your tests as that may well explain why it crashes.
Also increasing one or both of the values in the registry will I think give you more 'buffer capacity' if you see what I mean. That's not official terminology.
:cool:

With luck someone else who has downloaded this will provide some useful feedback for you.
 

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
Thanks - it helps a lot to discuss these things with someone. At the very least, I have to get my own thoughts in order well enough to explain them, which often starts me on a viable path. I'll post back here with how it turns out.
 

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
Next phase - I tried maxing out the cascade level, by adding a control, adding another control to that and another and so on. Got to just over 6,000 before it crashed. The visual is kind of comical - it kicks out and down, expanding across the screen to the right edge, then turns back to the left, constantly going down, until it reaches the bottom edge of the screen. I was wondering if it would start up again, but no - it travels back and forth across the bottom edge of the screen, up to cascade number 61 and there it stops. It will not expand any further, even though it successfully created nesting 6,000 levels deep. It's looking more and more to me like nobody ever thought about any limits to this process, or at least do no checking of any limits during runtime. It goes along until it crashes, even making things that it can't ever use, like nesting to 6,000+ levels deep.

In any case, this is getting interesting. If I have time to conduct enough experiments to be sure I know what I'm talking about, I may even consider writing an article on this process. I haven't seen any good ones, and believe me, I've looked.
 

Attachments

  • Cascade.jpg
    Cascade.jpg
    80.1 KB · Views: 108

isladogs

MVP / VIP
Local time
Today, 23:38
Joined
Jan 14, 2017
Messages
18,212
Looking at your screenshot, its a bit like a deck of cards being distributed on the screen.
You could create your own version of Solitaire in Access.

As for a detailed article, see chapter 11 in the Access 2000 Developers Handbook - mostly about programming with Command Bars.
I haven't studied that chapter so don't know if it covers what you are doing
 
Last edited:

Petr Danes

Registered User.
Local time
Tomorrow, 00:38
Joined
Aug 4, 2010
Messages
150
I have that book (both volumes) and it is a gold mine of information. That's where I got the original idea to build these things. Unfortunately, it covers this particular subject fairly sparsely, and devotes some of the space to the graphic interface, which has been removed in newer versions. Still, it would probably be worth going over it again - there is undoubtedly some stuff I've forgotten, and a review would not hurt. Thanks for the tip.
 

isladogs

MVP / VIP
Local time
Today, 23:38
Joined
Jan 14, 2017
Messages
18,212
I thought you would have as you said this was originally done in A2000.
Perhaps you can do me a favour now.
I recently bought replacement copies of both volumes as someone 'borrowed' mine years ago. I have the accompanying CD for vol 2 but not for vol 1. Would you be able to copy the CD for me. If so, I cam set up a shared Dropbox folder you can use.
Thanks in advance
 

Users who are viewing this thread

Top Bottom