[database] MS Access: how to compact current database in VBA

Application.SetOption "Auto compact", False '(mentioned above) Use this with a button caption: "DB Not Compact On Close"

Write code to toggle the caption with "DB Compact On Close" along with Application.SetOption "Auto compact", True

AutoCompact can be set by means of the button or by code, ex: after importing large temp tables.

The start up form can have code that turns off Auto Compact, so that it doesn't run every time.

This way, you are not trying to fight Access.