Auto Close Program when No Activity

Download Sample Access File: Auto Close Program when No Activity

This sample download file is a small file that will automatically close your Access program when there is no activity. The program will close in certain minutes when no activity. I have created a table IdleTime to enter a minute of non-activity.  In this sample file, I set the idle time to 2 minutes. However, you can change to the minutes you want.

How It Works:

  1. Open MS Access file
  2. The Detect Idle Form will open as hidden form
  3. The idle time will trigger when no activity on form
  4. The idle time will reset to 0 every time when there is an activity on form
  5. If there is no activity and the idle time reaches the minutes you set on IdleTime table then it will open an Alert Message form.
  6. If the user click OK button on the Alert Message form, the idle time will reset to 0 and start counting again.
  7. The Alert Message form will stay opening for 1 minute (60 seconds). If the user does not click OK button, the MS Access program will close.

Highlight functions in this file include:

#1 Customer Form

 The idle time function will work only when at least one form is opened. So I used the Customer form to test in this sample file. This Customer form is loaded when this sample is opened. It is an active form in this sample file. The idle time function will work on any of your form that is an active form on your database. You don’t need to copy this Customer form or Cutomer table to your program. I just used it to test the function.

#2 IdleTime table

I created this table in order to save the idle time in a minute that you can change it later as you want. You don’t have to change it under the VB code of the DetectIdle Time form. For this example file, I enter 2 minutes for the idle time. If there is no activity in 2 minutes then the Alert Message form will open.

#3 Alert Message Form

If there is no activity in 2 minutes then the Alert Message form will open. There is a count-down counter the starting from 59 to 0 on the right hand corner of the Alert Message. It means that this Alert Message form will stay opening for 1 minute (60 seconds).

  • If the user click OK button, the idle time will reset to 0 and start counting again.
  • If the user does not click OK button, the MS Access program will close when the counter drops to 0 or the Alert Message is opened for 60 seconds.

#4 Alert Message Form with 20 Seconds Remaining

The count-down counter will display in Red color when it counts to 20. The picture below displays 18 in red since it is below 20.  If the user click OK button, the program will cancel the Auto Close function and the idle time will reset to 0 and start counting again.

 

Download file contains:

2 Tables, 3 Forms, and 1 Macro

 

Related posts