Reminder Notice

slovell

Registered User.
Local time
Yesterday, 23:06
Joined
Sep 7, 2007
Messages
15
Hi All,
Newbie question for you.
I have a form that holds the current time (running time) and what I would like to do is at certain times have a reminder text box pop up that tells the user to check a certain report. So when .txtCurrentTime = 11:00 A.M. I want a message box to pop up reminding them to Check the report, at 9:00 A.M. I want it to say something else. There will be several other tasks as well.

The user will have this form open all day, and the time is a running time but I can't figure out how to get a message box to pop up at specific times.

Any help would be appreciated.
 
The form has a timer event you can use for things like this, in conjunction with the timer interval. Play with those and see where you get.
 
Thanks for the quick answer.
I will play around with this.
 
Stuck!!

O.k. I have the On Timer event working to track the current time.
I have multiple If statements telling a message box to pop up if the text box value is equal to a specific time which are not working.

I'm looking for the correct syntax for possibly a Case statement for the following: (I wan't message boxes to appear at the following times"

9:00 A.M. - Begin
10:30 A.M. - Check report
11:05 A.M. - Begin phase 2
12:00 P.M. - Do something else
1:00 P.M. - Begin Phase 3
3:00 P.M. - Call someone
4:30 P.M. - Schedule something
6:00 P.M. - Begin Phase 4
7:00 P.M. - Begin Phase 5
9:00 P.M. - Validate all phases
- 2 check all scoreboards
- Ensure descriptions are included for failures.

if anyone coule help it would be greatly appreciated.
 
What does your test look like? You probably need to test with 2 times (between 9:00 and 9:01), since testing for an exact time would be difficult, due to the seconds. Also, what is the timer interval?
 
I hope I'm answering your question right here:

I have an unbound text box named .txtCurrentTime. I have the form timer interval set to 1000, and on the OnTimer event I have the following code:

Private Sub Form_Timer()
'// update current time
With Me
.txtCurrentTime = Time()
End With
End Sub

What I want to happen is when the .txtCurrent time = (Times listed in last post, including seconds) I want a message box to pop up reminding the user to do something.

I had several IF statements nested, but only on or two would work...it would not go on past the second if statement. I'm thinking that a Case statement might be better, but I'm not sure of what the syntax would be....
 
I was looking for the IF statements, as that's probably where the breakdown is. IF vs Case is sort of a personal preference; either should work fine. I probably would use Case with this many options, but the key is probably how you're testing the value.
 
if me.txtCurrentTime = "9:00:00 AM" Then
msgbox "Phrase goes here",vbexclamation
if me.txtCurrentTime = "10:30:00 AM" Then
msgbox "Phrase goes here",vbexclamation
if me.txtCurrentTime = "11:00:00 AM" Then
msgbox "Phrase goes here",vbexclamation
if me.txtCurrentTime = "11:30:00 AM" Then
msgbox "Phrase goes here",vbexclamation
End if
End if
End if
End if
EndSub

These IF statements were in the OnTimer...there was actually about 4 or 5 more under the last one, but they are all pretty much the same.
 
With indenting, you might see the problem with that logic:
Code:
  If Me.txtCurrentTime = "9:00:00 AM" Then
    MsgBox "Phrase goes here", vbExclamation
    If Me.txtCurrentTime = "10:30:00 AM" Then
      MsgBox "Phrase goes here", vbExclamation
      If Me.txtCurrentTime = "11:00:00 AM" Then
        MsgBox "Phrase goes here", vbExclamation
        If Me.txtCurrentTime = "11:30:00 AM" Then
          MsgBox "Phrase goes here", vbExclamation
        End If
      End If
    End If
  End If
The problem is the only way code gets to the inner tests is if the first test is met, which of course would mean they would never be met. You'd want

If first test Then

ElseIf second test Then

ElseIf third test Then

End If

Also, you're testing for a text value "9:00:00 AM" but your textbox contains a time, so you'd want #9:00:00 AM#. I also suspect you'll have problems matching an exact time, because of seconds/milliseconds. You might test for

If Time > #9:00 AM# And Time < #9:01 AM# Then

and change your interval to every 55 seconds or something like that. Or maybe

If Format(Time(), "short time") = "9:00"

Because the format function will make it a text value.
 
Well there's your problem....

Let's say the time is 10:30 AM....

the code as described reads...

Code:
if Me.txtCurrentTime = #9:00 am# then
'...do something (all the stuff in the middle only runs if the first condition is true)
End if

that's it.

You would need to use the else clause thus:

Code:
if Me.txtCurrentTime = #9:00 am# then
...do something
ELSE
...do something different
end if

So, since you have several nested ifs then your code might look like:

Code:
if Me.txtCurrentTime = #9:00 AM# then 
   msgbox "Phrase one goes here",vbexclamation
Else
[COLOR="Lime"]   if Me.txtCurrentTime = #10:30 AM# then
   msgbox "Phrase two goes here",vbexclamation
   Else
   [COLOR="RoyalBlue"]'another test etc, etc[/COLOR]
   End if[/COLOR]
End if

Or you could use an elseif statement

Code:
if Me.txtCurrentTime= #9:00 am# then
   Msgbox...blah blah
Elseif Me.txtCurrentTime= #10:30 am# then
   Msgbox more blah blah
Elseif Me.txtCurrentTime = whatever
   '...etc
End if



But as Paul suggested, a select case statement is a lot cleaner and easier to read

Code:
Select Case Me.txtCurrentTime
Case #9:00 AM#
   msgbox "Phrase 1 goes here",vbexclamation
Case #10:30 AM#
   msgbox "Phrase 2 goes here",vbexclamation
Case #11:00 AM#
   msgbox "Phrase  3 goes here",vbexclamation
Case #11:30 AM#
   msgbox "Phrase 4 goes here",vbexclamation
Case Else
'do you want something to happen if none of the values are met?
End Select

Just beware that if your timer is not being run every second, consecutive timer 'events' might occur at say, 8:59:36 AM and 9:00:36 AM. Neither of which actually equal 9:00 AM.

If your timer is being run once a minute, for example, you may wish to specify a one-minute time interval to check for.

Something like

Case #8:59:01 AM# TO #9:00:00 AM#
...instead of...
Case #9:00 AM#

[Edit] Sorry Paul...missed your last post while typing (Must learn to type quicker! ;) )
 

Users who are viewing this thread

Back
Top Bottom