Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use On Timer to quit when no acitivity for 1 hr. 3

Status
Not open for further replies.

steve728

Programmer
Mar 16, 2003
536
US
Will someone please give me a code sample of how to set a form's timer event to call docmd.quit when there has been no keyboard activity for 1 hour?

Thanks in advance!

Steve
 
Here is one FAQ:
Automatically logging out idle users
faq181-1432
I think there are more.
 
Never tried it - interesting question. I have some thoughts here, though I haven't tried it out.

First you would have to be sure you only have one form open at a time which would accept keyboard activity.

Then (on each possible form) do the following:

Code:
Private lastKeyPress As DateTime  'formlevel variable

Private Sub Form_KeyPress(KeyAscii As Integer)
  lastKeyPress = now()
End Sub

Private Sub Form_Timer()
Dim interval As Double
Dim hours As string

interval = now() - lastKeyPress
hours = Format(interval, "h")

if hours = "0" Then
    'do nothing
else
    DoCmd.Quit
End If
End Sub

End If

Probably you would need the timer interval in the form properties set to run every 1 to five minutes or so. (it is in milliseconds, so you'll need to calculate exactly how ovten you want it to run.)
 
Here is another FAQ that works well to log out idle users

thread702-1301504

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top