Code for a timeout

Pappy

Registered User.
Local time
Today, 11:05
Joined
Jun 12, 2003
Messages
28
How would I go about kicking out a user if he is idle for 15 minutes? The users do not log on to the database. T

he tables are based in SQL and access serves as the front.

All help is appreciated
 
what I've got

Here is my code I've been keying with, from my kick post. I want to have a msgbox pop up, and give them the option. If they don't click on anything for say another 10 mins, I then put them off. Right the timings are set to 5 or 10 sec just to play with it. Take a look and show me how I should set up my loop. Thanks




Private Sub Form_Timer()

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim strSQL As String
rs.Open "tblLogout", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rs.MoveFirst
If rs!Logout = True Then

Msg = "You have been idle for 10 mins. Do you wish to keep the database open?" ' Define message.

Style = vbYesNo ' Define buttons.
Title = "IDLE TIME" ' Define title.
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
Do

If Response = vbYes Then ' User chose Yes.

Else: 'User Chose No

Application.Quit 'Quit Out
End If
Loop While (Pause(5) = False)

Application.Quit 'Quit Out

End If
rs.Close
Set rs = Nothing

End Sub
Public Function Pause(NumberOfSeconds As Variant)
On Error GoTo Err_Pause

Dim PauseTime As Variant, Start As Variant

PauseTime = NumberOfSeconds
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop

Exit_Pause:
Exit Function

Err_Pause:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_Pause

End Function
 
There are a couple of things I would comment on with this method.

1. By using a message box. If the Db is idle, they may not click on the Yes/No button and therefore remain logged in and still remain idle.

2 By using the Pause in the code, it means that unneccessary processor time is used evaluating the pause before continuing (especially if it is 10 minutes).
You are using the Form_Timer event so rather than using a pause, set the TimerInterval to the value you wast to wait for. It seems inefficiant to have a pause in a timer code whrn all you need to do is set the timet time more appropriately.

3. if you have any systems running A97.
this..
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

Will not work.
 

Users who are viewing this thread

Back
Top Bottom