Timer event not working.

R

Rpettis31

The form load code which is similar to this works. Idea is that I am able to
log people out of a database when I need to do maintenance or they forgot to
log out from the previous day. The timer code does not seem to be working
Private Sub Form_Timer()

Dim db As DAO.Database
Dim snp As DAO.Recordset
Dim msg As String, intLogoff As Integer
Set db = CurrentDb
Set snp = db.OpenRecordset("tblSettings", dbOpenSnapshot)
intLogoff = snp![LogOff]
snp.Close
db.Close

If intLogoff = True Then
If Me.Tag = "MsgSent" Then
Application.Quit (acQuitSaveAll)
Else
Me.Tag = "MsgSent"
DoCmd.OpenForm "frmExitNow"
End If
End If

End Sub
 
D

Dale Fye

What is the TimerInterval set to on your form?

If you want to give your users a chance to actually close the db before they
are forced off, I'd make it several minutes. Actually, you might want to use
the Tag property to track the number of minutes since frmExitNow was
presented. Start with 0, add 1 each time the TimerInterval code fires (every
minute maybe) and when it reaches 5, force them off.

If me.Tag = 4 then
Application.Quit
elseif len(me.Tag & "") = 0 then
me.Tag = 0
docmd.openform "frmExitNow"
else
me.tag = val(me.tag) + 1
endif
 
J

JimBurke via AccessMonster.com

You need to set the timer interval - are you doing that in the Load event?
Somehwere in it you need

Me.TimerInterval = your interval here

The interval is in milliseconds, so, e.g. for 1 second you need an interval
of 1000. If you already have that and it's not working, then I'm not sure
what the problem might be.
The form load code which is similar to this works. Idea is that I am able to
log people out of a database when I need to do maintenance or they forgot to
log out from the previous day. The timer code does not seem to be working
Private Sub Form_Timer()

Dim db As DAO.Database
Dim snp As DAO.Recordset
Dim msg As String, intLogoff As Integer
Set db = CurrentDb
Set snp = db.OpenRecordset("tblSettings", dbOpenSnapshot)
intLogoff = snp![LogOff]
snp.Close
db.Close

If intLogoff = True Then
If Me.Tag = "MsgSent" Then
Application.Quit (acQuitSaveAll)
Else
Me.Tag = "MsgSent"
DoCmd.OpenForm "frmExitNow"
End If
End If

End Sub
 
R

Rpettis31

I forgot to change the timer property on the form from zero...LOL...

Thanks for your help.

Dale Fye said:
What is the TimerInterval set to on your form?

If you want to give your users a chance to actually close the db before they
are forced off, I'd make it several minutes. Actually, you might want to use
the Tag property to track the number of minutes since frmExitNow was
presented. Start with 0, add 1 each time the TimerInterval code fires (every
minute maybe) and when it reaches 5, force them off.

If me.Tag = 4 then
Application.Quit
elseif len(me.Tag & "") = 0 then
me.Tag = 0
docmd.openform "frmExitNow"
else
me.tag = val(me.tag) + 1
endif

----
HTH
Dale



Rpettis31 said:
The form load code which is similar to this works. Idea is that I am able to
log people out of a database when I need to do maintenance or they forgot to
log out from the previous day. The timer code does not seem to be working
Private Sub Form_Timer()

Dim db As DAO.Database
Dim snp As DAO.Recordset
Dim msg As String, intLogoff As Integer
Set db = CurrentDb
Set snp = db.OpenRecordset("tblSettings", dbOpenSnapshot)
intLogoff = snp![LogOff]
snp.Close
db.Close

If intLogoff = True Then
If Me.Tag = "MsgSent" Then
Application.Quit (acQuitSaveAll)
Else
Me.Tag = "MsgSent"
DoCmd.OpenForm "frmExitNow"
End If
End If

End Sub
 
C

CK

I would like to try your code to give 5 minutes to the users in case they
want to finish something off. Could you explain how I might use this combined
with the Detect idle time function which I found on this page?

http://support.microsoft.com/default.aspx?scid=kb;en-us;210297

I understand I need to modify the IdleTimeDetected Module, but I can't quite
figure out where this tag should be defined?

--
CK


Rpettis31 said:
I forgot to change the timer property on the form from zero...LOL...

Thanks for your help.

Dale Fye said:
What is the TimerInterval set to on your form?

If you want to give your users a chance to actually close the db before they
are forced off, I'd make it several minutes. Actually, you might want to use
the Tag property to track the number of minutes since frmExitNow was
presented. Start with 0, add 1 each time the TimerInterval code fires (every
minute maybe) and when it reaches 5, force them off.

If me.Tag = 4 then
Application.Quit
elseif len(me.Tag & "") = 0 then
me.Tag = 0
docmd.openform "frmExitNow"
else
me.tag = val(me.tag) + 1
endif

----
HTH
Dale



Rpettis31 said:
The form load code which is similar to this works. Idea is that I am able to
log people out of a database when I need to do maintenance or they forgot to
log out from the previous day. The timer code does not seem to be working
Private Sub Form_Timer()

Dim db As DAO.Database
Dim snp As DAO.Recordset
Dim msg As String, intLogoff As Integer
Set db = CurrentDb
Set snp = db.OpenRecordset("tblSettings", dbOpenSnapshot)
intLogoff = snp![LogOff]
snp.Close
db.Close

If intLogoff = True Then
If Me.Tag = "MsgSent" Then
Application.Quit (acQuitSaveAll)
Else
Me.Tag = "MsgSent"
DoCmd.OpenForm "frmExitNow"
End If
End If

End Sub
 

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