Mike,
This has probably been viewed by numerous people...
And any considering replying have decided it's too complicated.
I "just happened" to have example code.
It's up to you to decide if this is "all complicated".
You need to create an On Timer event for the form and copy the following code into it. Also, you need to set the Timer Interval property to how often you want to have the elapsed idle time checked. 10000 = Check every 10 seconds as the field is in milliseconds. Don't reduce this too much because it's going to be executing even when the user is actively using the form. In my case, I didn't want to close the form, just notify the user of idle time - I commented those lines by putting ' at the beginning.
Private Sub Form_Timer()
' IDLEMINUTES determines how much idle time to wait for before
' running the IdleTimeDetected subroutine.
Const IDLEMINUTES = 5
Static strPrevControlName As String
Static strPrevFormName As String
Static sngExpiredTime As Single
Dim strActiveFormName As String
Dim strActiveControlName As String
Dim sngExpiredMinutes As Single
On Error Resume Next
' Get the active form and control name.
strActiveFormName = Screen.ActiveForm.Name
If Err Then
strActiveFormName = "No Active Form"
Err = 0
End If
strActiveControlName = Screen.ActiveControl.Name
If Err Then
strActiveControlName = "No Active Control"
Err = 0
End If
' Record the current active names and reset sngExpiredTime if:
' 1. They have not been recorded yet (code is running
' for the first time).
' 2. The previous names are different than the current ones
' (the user has done something different during the timer
' interval).
If (strPrevControlName = ""

Or (strPrevFormName = ""

_
Or (strActiveFormName <> strPrevFormName) _
Or (strActiveControlName <> strPrevControlName) Then
strPrevControlName = strActiveControlName
strPrevFormName = strActiveFormName
sngExpiredTime = 0
Else
' ...otherwise the user was idle during the time interval, so
' increment the total expired time.
sngExpiredTime = sngExpiredTime + Me.TimerInterval
End If
' Does the total expired time exceed the IDLEMINUTES?
sngExpiredMinutes = (sngExpiredTime / 1000) / 60
If sngExpiredMinutes >= IDLEMINUTES Then
' ...if so, then reset the expired time to zero...
sngExpiredTime = 0
' ...and call the IdleTimeDetected subroutine.
IdleTimeDetected sngExpiredMinutes
End If
End Sub
Sub IdleTimeDetected(sngExpiredMinutes)
Dim strMessage As String
'strMessage = "No user activity detected in the last" & vbCrLf
'strMessage = strMessage & sngExpiredMinutes & " minute(s)!"
'MsgBox strMessage, vbInformation, "No Sign of Activity!"
DoCmd.Close
End Sub
HTH,
Bob
Thread181-473997 provides information regarding this site.