Help with closing this form please

  • Thread starter Thread starter Shadow
  • Start date Start date
S

Shadow

I have a form in a database and need to close this form after a certain
period of time, if the user doesn't use this form.
Is it possible?


thanks for any kind of advice.

Shadow
 
I have a form in a database and need to close this form after a certain
period of time, if the user doesn't use this form.
Is it possible?

Let's say you want it to close in ten minutes. Set the form's Timer
property to 600000 (600,000 milliseconds is ten minutes). Also put a
global variable gOKToClose As Boolean in the form's module, before any
of the Sub lines.

Invoke the Code Builder on the form's Timer event and edit it to:

Private Sub Form_Timer()
If gOKToClose = True Then
DoCmd.Close acForm, Me.Name
Else
gOKToClose = True
End If
End Sub

In the Form's Current event put

Private Sub Form_Current()
gOKToClose = False
End Sub

The effect of this is that whenever the user opens the form, or moves
from one record to another, the variable will be set to False. Every
ten minutes the Timer event will check the value of the variable. If
it's False (because the user has done something in the past ten
minutes) it will just toggle the variable to True. Ten minutes later
it will check again - if the user has done nothing, it will close the
form.
 
Great. It's simply great. Thanks for sharing your wisdom. I'm off to give it
a try.
thanks a million.


Shadow
 
Back
Top