knock off idling user.

  • Thread starter Thread starter lilbit27
  • Start date Start date
L

lilbit27

Hello I am using the following code to know off a user after a certain
time. Does anyone know how I can change the time from being 1 minute to
20. Do I just change the intidleminutes to = 20 then what do i put on
under the time interval


Const c_intIDLEMINUTES = 1 '30
Static strPrevCtlName As String
Static strPrevFrmName As String
Static lngExpiredTime As Long

Dim strActiveFrmName As String
Dim strActiveCtlName As String
Dim lngExpiredMinutes As Long

On Error Resume Next


strActiveFrmName = Screen.ActiveForm.Name
If Err Then
strActiveFrmName = "No Active Form"
Err = 0
End If

strActiveCtlName = Screen.ActiveControl.Name
If Err Then
strActiveCtlName = "No Active Control"
Err = 0
End If

txtActive.Text = strActiveCtlName & ";" & strActiveFrmName

If (strPrevCtlName = "") Or (strPrevFrmName = "") Or (strActiveFrmName
<> strPrevFrmName) Or (strActiveCtlName <> strPrevCtlName) Then
strPrevCtlName = strActiveCtlName
strPrevFrmName = strActiveFrmName
lngExpiredTime = 0
Else
lngExpiredTime = lngExpiredTime + Me.TimerInterval
End If

lngExpiredMinutes = (lngExpiredTime / 1000) / 60
If lngExpiredMinutes >= c_intIDLEMINUTES Then
'this user has to be kicked off
lngExpiredTime = 0
Application.Quit acQuitSaveAll
End If
End Sub
 
It depends on how often you want to check before you kick them off.

If you set the TimerInterval equal to

millisec code runs every
---------------------------------
1000 = 1 sec.
5000 = 5 sec
60000 = 60 sec (1 min)
300000 = 300 sec (5 min)


FWIW, I made a couple of changes w/comments to the code. See below

'**** snip ******
If (strPrevCtlName = "") Or (strPrevFrmName = "") Or (strActiveFrmName
<> strPrevFrmName) Or (strActiveCtlName <> strPrevCtlName) Then
strPrevCtlName = strActiveCtlName
strPrevFrmName = strActiveFrmName
lngExpiredTime = 0
'no need to process more lines
Exit Sub '<<added
Else
lngExpiredTime = lngExpiredTime + Me.TimerInterval
End If

lngExpiredMinutes = (lngExpiredTime / 1000) / 60
If lngExpiredMinutes >= c_intIDLEMINUTES Then
' not needed
'lngExpiredTime = 0

' ********
'acQuitSaveAll saves changes to objects (forms,queries,reports)
' *not* data entered. To save changed data use:

'If Me.Dirty then
' Me.Dirty = False
'End If

'this user has to be kicked off
'Application.Quit acQuitSaveAll
Application.Quit acQuitSaveNone
End If
End sub
'***********************

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top