Go to Top

Getting “System Resource Exceeded” messages? Here’s one way to fix it

System Resource Exceeded Error Message

Lately we’ve been seeing a barrage of clients getting “System Resource Exceeded”  when migrating to Windows 10, even though the system worked fine in prior versions of Windows. In some cases we’ve traced the issue to apps that use a lot of subforms in a tab control, so I’m going to describe a technique that will prevent the issue in those cases when each tab hosts a subform.

Tabs Make For Great UI – Until the memories run out

Just the other day I was working with a client’s app that was three tab levels deep: tabs within tabs, all of which were being loaded with subforms every time the form was opened. The app worked fine in Windows 7 but caused “System Resource Exceeded” error messages in Windows 10. The solution is to only load the subform when the user clicks on the tab and unload the subform when they click off to another tab.

ADVERTISING
ACCESS SAFETY AND TRAINING DATABASE

Code Review

The magic happens on the tab’s Change event, which occurs when the user clicks on each tab of the control.  In the code sample above I’m only interested in tabs that have subforms, in this case three tabs. (The technique is useless for tabs without subforms).

The static LastSubForm object, (line 10), keeps track of the last subform used and sets its SourceObject value to null in line 16. This will vacate the prior tab’s form from memory and keep memory use down to a minimum when the user switches off to another tab.

The select statement in line 22 is used to identify which tab was clicked on, then set the LastSubForm object to the subform contained in the tab and finally setting the SourceObject of the subform in line 28. Doing so will immediately load the subform into memory. The processed is repeated for the other two tabs of the control with subforms.

Keep In Mind

In order to minimize memory use you need to set the SourceObject property of each tab in question to an empty string in design view, otherwise all the subforms will load, which defeats the purpose of the technique.

The first tab of your control should load since it’s what your users will see when they open your form.

Just add more select statements as needed if you need to use this technique with more tabs, I’ve used it for a tab control that had 8 tabs.

If you have nested tabs you will need to repeat the approach for each tab control.

If your subform names are the same as your SourceObject property, you can further optimize the code by using a string variable in the code. 

If you like this post share it!

Please share this post on LinkedIn, Twitter and Facebook, it will be much appreciated!

Join me on th enext Access with SQL Server meeting May 8th, at 6:30 PM CST, for more details please click here

 

About Juan Soto

Juan Soto is a Senior Access Developer at IT Impact Inc. and a Microsoft Access MVP. He specializes in Access with SQL Server databases. His passion for Access has led him to helping a wide range of businesses in helping them establish a secure, stable and efficient environment with SQL Server. He's a frequent speaker at Access user groups nationwide and recently spoke at the Orange County SQL Saturday # 73. If you wish to have Juan speak at your next group meeting you can contact him here.

One Response to "Getting “System Resource Exceeded” messages? Here’s one way to fix it"

  • CW
    May 12, 2018 - 6:14 am Reply

    For a while after my company switched to Windows 7, we were getting “System resource exceeded” errors when using or compacting Access files. The fix turned out to be (strangely enough) limiting the MSAccess.exe process to 4 or fewer processors.

    The number of processors can be changed manually in Windows Task Manager. Go to the Processes tab, right-click on the MSAccess.exe process, click “Set Affinity…” and uncheck all but 4 processors. (I’m using Windows 7 still, so the steps might be different in Windows 10.)

    You can also set the affinity programmatically like so:

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Contact Us
close slider
  • This field is for validation purposes and should be left unchanged.