Ref: Close Form After Certain Amount Of Time

L

ll

John,
I have been trying this great code out (below) with my Access
application, and while the form closes after 2 minutes, the form
actions (clicking in a field, changing values) do not reset the
FormIsActive value to True, as the form closes 2 min from the time it
is opened, regardless. Should the FormIsActive variable be a certain
kind of variable, such as string, boolean, etc? I've set all of my
form controls to set FormIsActive to True on the OnChange() event,
such as:

Private Sub cboBuyerProjectDueDate_Change()
Set FormIsActive = True
End Sub


On my form, I've set FormIsActive to True in the OnOpen() event of the
form and I've set the form's TimerInterval to 120000 (2 minutes) as
specified.


In the OnTimer event I've put code:

'////at the top
Option Compare Database
Public FormIsActive
'///question: Do I declare the FormIsActive variable as a '\\\string
or boolean?


Private Sub Form_Timer()
If FormIsActive Then
FormIsActive = False
Else
DoCmd.Close acForm, "yourformname"
End If
End Sub

Private Sub Form_Current()
FormIsActive = True
End Sub
'\\\\\\\\\\\\\\\

I've got a msgbox in the Form_Open() event that displays the
FormIsActive value. It displays as "True" when I open the form:

Private Sub Form_Open(Cancel As Integer)
FormIsActive = True
MsgBox FormIsActive
End Sub



I have msgbox'es in all of my form field onChange() events, but they
aren't working (displaying) when the fields are changed:

Private Sub cboEmplName_Change()
Set FormIsActive = True
MsgBox FormIsActive
End Sub

Private Sub txtprojectName_Change()
Set FormIsActive = True
MsgBox FormIsActive
End Sub


'\\\\\\\\\\\\\\\\\\\\\\
Thanks for any help you might be able to provide.

Kind Regards,
Louis







'\\\\\\\\\\\\\\\\
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top