Access settings stack in VBA

This is a similar piece of code as the ExcelSettingsStack posted earlier.

It does pretty much the same thing, but has some differences due to Excel settings being read/write and Access settings mostly being write-only. It provides the same two base functions; Push and Pop. The Push function stores the provided settings (or current settings for all optionals left blank) and sets them. Upon Pop, the previous settings on the stack are restored. If settings are write-only, the previous value on the stack is used as the current setting. The current setttings can be retrieved through the Last property.

[ad name=”468×60 Banner”]

Application properties included

  • Application.Screen.MousePointer : Mousepointer shown
  • Application.Echo : Should the screen be updated while running code
  • DoCmd.SetWarnings : Should alerts be displayed
  • StatusBar (through SysCmd) : False if statusbar text is Access controlled, or string if custom message

Sample use

  • Everytime foreign code is called which might change settings, call Push just before calling the code. And call Pop after returning, this way your code will not be influenced by changes made to the settings by the foreign code.
  • In each function or sub that changes settings, at its start, call Push, with the required settings. Upon exiting call Pop to restore previous settings. After calling some foreign code call Apply, to re-apply the last settings on the stack (without popping).

Sample code

Create a module and add the following statement to create a public stack;

[code lang=”vb”]Public AccessSettings As New clsAccessSettingsStack[/code]

At the start of your function/sub add;

[code lang=”vb”]AccessSettings.Push MousePointer:=acHorizontalResize, _
                   StatusBar:=”Here’s a status bar text”[/code]

Add your code here…

At the end of your code add;

[code lang=”vb”]AccessSettings.Pop[/code]

Remember: Always use Pop after Push or it will be out-of-sync!


  • clsAccessSettingsStack.Push : Puts the provided settings on the stack and applies them
  • clsAccessSettingsStack.Pop : Restores the previous settings, returns true/false for success
  • clsAccessSettingsStack.Size : Read-only, reports back the size of the stack
  • clsAccessSettingsStack.Reset : Resets the stack to the size requested, reports true/false for success
  • clsAccessSettingsStack.Apply: Applies the last settings on the stack, without popping them
  • clsAccessSettingsStack.Last: Returns the last settings on the stack ( = current settings)


Download sample with code (downloaded 883 times).

[ad name=”468×60 Banner”]

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe without commenting