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