Detect idle time on MS Access form

How to calculate the idle time of user in Microsoft Access..

This article explains how to calculate the idle time of user in Microsoft Access. This article demonstrate the how to detect idle time using procedure on Microsoft Access form.

To calculate the idle time firstly we have to insert blank form from Access Ribbon. Then we have to set the form property "time interval =1000" and on the "On Timer" event we have write the procedure as shown in Fig 1.1.

Track system inactive time using VBA Fig-1.1


Then we have to write the macro action "open Form" window mode to hidden and other arguments also as shown in Fig 1.2.

Track system inactive time using VBA Fig-1.2


Now open the Access Form in Form view. To test the inactivity, does nothing on Access Form. After one minute you will see a message will pop up with time as shown in Fig 1.3.

Track system inactive time using VBA Fig-1.3



Option Compare Database
Sub IdleTimeDetected(exmin)
Dim Msg As String
Msg = Msg & exmin & "minute(s)!"
MsgBox Msg, 50
End Sub
Sub Form_Timer()

Dim precontrol As String
Dim prevform As String
Dim extime
Dim Currentform As String
Dim currentcontrol As String
Dim exmin

On Error Resume Next
Currentform = Screen.ActiveForm.Name
currentcontrol = Screen.ActiveControl.Name
If Err Then
currentcontrol = "Not active"
Err = 0
End If
If (precontrol = "") Or (prevform = "") Or (Currentform <> prevform) Or (currentcontrol <> precontrol) Then
precontrol = currentcontrol
prevform = Currentform
extime = 0
extime = extime + Me.TimerInterval
End If
exmin = (extime / 1000) / 60
Do While exmin >= IDLEMINUTES
extime = 0
IdleTimeDetected exmin
End Sub


It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. Access Guru will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.