1. I don't know if I would trust automating operations like this.
2. All users *must* be out of the DB in order to Compact.
a. You cant reliably run code "inside" the DB and make it compact itself.
3. Having this on a Timer has it's own issues:
a. Timers use up lots of system resources
b. The timer must be on a hidden form, that is always open
c. What if the machine is in "sleep" mode?
d. What if the machine is in "Hibernate" mode?
e. What if the machine is turned off
f. What if the user is logged off?
I am sure there is a method to do this manually, but here is a utility that will manage both tasks for you:
http://www.fmsinc.com/MicrosoftAccess/Scheduler.html;-)
JeffCoachman