stop watch

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

I have seen some of the traffic back and forth on this
subject, still unsure how to affect the following:

A hidden form tracks how long since the user has
interacted with the database. When the time elapsed
equals five minutes, the session terminates.

Any guidance to the right path is greatly appreciated.

On form open, timer = 0
On database activity, timer reset to 0

Timerinterval = 1000
Timer = Timer + Timerinterval

When Timerinterval = 300000, docmd.quit
 
Hi,

Not exactly how I would do it. Leave the timerinterval to 1000 ( one
second ). Have a global variable, for the form, in the declaration section

Option Compare Database
Option Explicit
Private LastActivity As Date


and set it to Now if there is activity (keyDown event of form, if the
form has its KeyPreview set to true):


LastActivity = Now( )



Next, in the onTimer event of the form, test if the difference in
seconds exceed 300 between Now and LastActivity, you can "leave" (or undo
the form then leave), if that is so:


If 300<= DateDiff("s", LastActivity, Now() ) then
Me.Undo
Application.Quit
End If


Hoping it may help,
Vanderghast, Access MVP
 
Back
Top