Time of day message

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Good day.

Looking for ideas of how to have a form or module check
the time of day and when it hits 2:00 p.m, for example,
to give me a msgBox or an alert of some kind.

Any ideas?

Thank you.
 
Steve,

It may be worth considering using Windows Task Manager, or a third party
scheduling utility, for this purpose, rather than running it from
Access. The only way I know of to run it from Access is to use the
Timer event of a form which is always open. You can set the Timer
Interval property of the form to 1000 (i.e. 1 minute), and then on the
On Timer event property, code the equivalent of...
If Format(Time, "hh:nn") = "14:00" Then
MsgBox "ding dong!"
End If

If you want to reduce some overhead, so the event is not being triggered
every minute for the whole day, you could set the Timer Intgerval of the
form to 60000 (i.e. 1 hour), and then on the Timer you can do something
like this...
If Hour(Now) = 13 Then
Me.TimerInterval = 1000
ElseIf Format(Time, "hh:nn") = "14:00" Then
MsgBox "ding dong!"
Me.TimerInterval = 60000
End If
 
Agree with Steve that using Access to control this is probably going to be
unreliable.... but one slight improvement... set the timer interval value
when the form gets loaded instead of running every hour (or whatever)....
something like...

Private Sub Form_Load()
Me.TimerInterval = DateDiff("s", Now, Date + #02:00:00 PM#) * 1000
End Sub

(that is, if you're convinced it's going to be opened before 2pm, but a
couple of Ifs and a DateAdd should get you around that)

....and then set the timer interval for the next time around in the timer
event itself.
 
Back
Top