Hello,
I currently have a form with the below code and a macro to open the hidden form when the database is opened. Overall, it works perfectly for when users are using forms frequently and kicks them if they are inactive.
However, there are some users who will leave a table open and inactive and this code does not kick the user from the database. I'm pretty new to coding in access so any help would be appreciated!
Code:
Private Sub Form_Timer()Static OldcontrolName As String
Static OldFormName As String
Static ExpiredTime
Dim ActivecontrolName As String
Dim ActiveFormName As String
Dim ExpiredMinutes
On Error Resume Next
ActivecontrolName = Screen.ActiveControl.Name
ActiveFormName = Screen.ActiveForm.Name
Me.txtActiveForm = ActiveFormName
If (OldcontrolName = "") Or (OldFormName = "") _
Or (ActiveFormName <> OldFormName) _
Or (ActivecontrolName <> OldcontrolName) Then
OldcontrolName = ActivecontrolName
OldFormName = ActiveFormName
ExpiredTime = 0
Else
ExpiredTime = ExpiredTime + Me.TimerInterval
End If
ExpiredMinutes = (ExpiredTime / 1000)
Me.txtIdleTime = ExpiredMinutes
If ExpiredMinutes >= 20 Then
ExpiredTime = 0
Application.Quit acQuitSaveAll
End If
End Sub