Auto Shutdown

paulscherm

Registered User.
Local time
Today, 15:56
Joined
Aug 27, 2012
Messages
16
Looking for VBA code to automatically shutdown my access database after it's been idle for certain period of time.

Thanks,
Paul:banghead:
 
This is an interesting question. I don't have a solution for you, but my initial thought is that you could write a timeout function to start a timer and then kill the database when the timer reaches a certain value using a simple docmd.quit instruction.

The trick would be to write a line of code at the beginning of every event driven block of code in your front end that would kill or preferably reset the timer. If you choose to kill the timeout function at the beginning of every block of event driven programming, you would then want to restart the timeout function at the end of every event driven code block. I have not used the timer function for several years but suspect that you could figure out if there is a way to reset/restart/kill the timer function through VBA code.
 
Last edited:
To achieve this I can only think of using a log table which records certain major events in your database, for example whenever a person opens the database, adds records to a certain table or runs a certain function and this then generates a new record in the log table which has a date/time field. With a log table in place you can check the time of the last entry and if Now() - DMax(log table) is greater than say an arbitary figure of 30 minutes the DoCmd.Quit
All you need now is a hidden form which remains open with a timer control to perform this check every xxxx seconds
David
 
DAVIDATWORK, you provided a great solution here. My assumption was that there would be that the database window was hidden and all users would be accessing the system via forms. click, mouse over, upon exit events would be the means to determine that a user is actively in the system.

PAULSCHERM, Creating a simple table that stores the logged in user with a timestamp from the last event driven activity is all that is needed. Each event driven activity would reset the timestamp using the now() function with a simple update query.
 

Users who are viewing this thread

Back
Top Bottom