Time interval to automatically close an Access application

I need to set up a time-out function in my access database.  Bascially, I want the application to close automatically if the user has not done anything with the form for 20 minutes.   I know there is a time interval on the form, but I cannot find anything that tells me how to use or program this.
Thanks
ssmith94015Asked:
Who is Participating?
 
skeeveswpConnect With a Mentor Commented:
The timer works by firing an event each time the timer interval is reached.  The timer interval is set in ms, so your 20 minutes is going to be ... 1200000 ms.  After the timer runs 20 seconds, the timer event fires, and you can close your application.

The trick is going to be resetting the timer each time a process runs.  The most effective way to do this is to set the timerinterval for the form object to 0 at the start of each process and then setting it back to 1200000 at the end of the process.  Setting the interval to 0 essentially resets the timer and disables it.  Setting it to a value will start it up again.

You can check this out with this code sample ...

Private Sub Command0_Click()
    Form_Form1.TimerInterval = 0
End Sub

Private Sub Command1_Click()
    Form_Form1.TimerInterval = 4000
    Text2 = CStr(Now())
End Sub

Private Sub Form_Timer()
    Text2 = CStr(Now())
End Sub

Note that I used three controls, two command buttons and a text box.  You can modify this to test a single command button by doing something like this:

Private Sub Command0_Click()
    if form_form1.Timerinterval = 0 Then
        form_form1.TimerInterval = 4000         ' 4 Seconds
        text2 = cstr(now())
    else
        Form_Form1.TimerInterval = 0
    end if
End Sub

Each time you click the command button the timer interval will be toggled, and if you are enabling the timer the start time and updating intervals will be displayed in the text box.

Hope that helps.

-- Seve
0
 
ssmith94015Author Commented:
I will try, this is more than I hoped for.
0
All Courses

From novice to tech pro — start learning today.