preventing Autoexec macro from running after Compact & Repair
Seems such a simple thing, but I can't find the answer anywhere.
Every time I Compact & Repair, my Autoexec macro runs again. Is there a way to prevent it from running here, as part of the reason for compacting is to get the file size back down again after the Autoexec has deleted a lot of rows.
You could rename the macro when you don't want it to operate as an autoexec macro.
DoCmd.Rename "disableAutoExec", acMacro, "AutoExec"
And rename it back to AutoExec when you do want it to behave as an autoexec macro.
If that suggestion isn't satisfactory, you could have the macro check for the presence of a file, disableAutoExec.txt, and do nothing when that file exists.
Delete the file when you do want AutoExec to do everything it's set up to do.
Or instead of a file as a flag to control whether AutoExec should proceed, you could store the flag value in a table.
an old one that works (in MS Access 2010 and before at least) is to hold down the shift key when opening the database