Option Compare Database
Option Explicit
Private Sub Form_Timer()
Dim ExpiredMinutes
Static ExpiredTime
' IDLEMINUTES determines how much idle time to wait for before running the IdleTimeDetected subroutine.
Const IdleMinutes = 1 'Minutes
' Increment the total expired time.
ExpiredTime = ExpiredTime + Me.TimerInterval
' Does the total expired time exceed the IDLEMINUTES?
ExpiredMinutes = (ExpiredTime / 1000) / 60
If ExpiredMinutes >= IdleMinutes Then
' ...if so, then reset the expired time to zero...
ExpiredTime = 0
' ...and call the IdleTimeDetected subroutine.
IdleTimeDetected ExpiredMinutes
End If
End Sub
Private Function IdleTimeDetected(ExpiredMinutes)
' MsgBox "No user activity detected in the last " & ExpiredMinutes & " minute(s)!", vbInformation, "Idle User"
Application.Quit acQuitSaveNone
End Function
Private Sub Form_Open(Cancel As Integer)
Static ExpiredTime
ExpiredTime = 0
End Sub