Display label or text box at specific time (1 Viewer)

adam12

Registered User.
Local time
Today, 08:25
Joined
Mar 2, 2007
Messages
10
I've searched the forum, cannot find anything for this. I want to display a label or text box (or if possible a msgbox) at a specific time of the day. My database is a 24hr op, so a user will always be on to see it.

Here's the code I tried.

If Time = 0800 Then
me.reminder.visible = true
else
me.reminder.visible = false
end if

I'm sure theres something better, but would appreciate anyone's help.
 

KenHigg

Registered User
Local time
Today, 08:25
Joined
Jun 9, 2004
Messages
13,327
Your if should check if now() is greater than or less than something using the 'On Timer' event of the form...
 

adam12

Registered User.
Local time
Today, 08:25
Joined
Mar 2, 2007
Messages
10
Should the code be in the OnTimer? Currently its in the OnCurrent. Now() is not in the equation right now.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:25
Joined
Feb 28, 2001
Messages
27,236
OnCurrent is ONLY evaluated after a change in the content of a form due to a navigation action or Save (or Undo) action. Use OnTimer to trigger putting up your special text item.
 

adam12

Registered User.
Local time
Today, 08:25
Joined
Mar 2, 2007
Messages
10
Ok, didn't work with the Code in the OnTimer. Is the code wrong, is there a different format for time?
 

KenHigg

Registered User
Local time
Today, 08:25
Joined
Jun 9, 2004
Messages
13,327
Try something a bit more simple - like getting a message box to pop up with the ontimer event. And did you set the time interval?
 

EdFred

knows enough, dangerous
Local time
Today, 08:25
Joined
Mar 2, 2007
Messages
129
Instead of the time being a specific time, how about a range?

I had something similar to this where I would want the inventory to be updated from my database to the website. I of course only wanted it to run once when I opened the database, not every time because it takes a while. So I made a table that checks the date in the table against Now(). If they are the same, don't do anything. If they are different, then run the code, and change the date in the table.
 

adam12

Registered User.
Local time
Today, 08:25
Joined
Mar 2, 2007
Messages
10
I tried to set a message box to open at a specific time, and couldn't. I'm pretty much a novice, and am probably using the wrong code. I'm not sure how to set up...
 

adam12

Registered User.
Local time
Today, 08:25
Joined
Mar 2, 2007
Messages
10
Can you show me how to run this when they are the same?


Instead of the time being a specific time, how about a range?

I had something similar to this where I would want the inventory to be updated from my database to the website. I of course only wanted it to run once when I opened the database, not every time because it takes a while. So I made a table that checks the date in the table against Now(). If they are the same, don't do anything. If they are different, then run the code, and change the date in the table.
 

Bat17

Registered User.
Local time
Today, 13:25
Joined
Sep 24, 2004
Messages
1,687
I would use a form that is opened when the database opens and set to invisible this way it will be running all of the time.
You use the timer event of the form to check if it is time to pop up the message. How frequently you check against the time depends on how accurate you need to be. In this example I am checking every 5 mins

Code:
Private Sub Form_Load()
Dim lngInterval As Double
' 1000 = 1 second so to check every 5 mins
lngInterval = CLng(1000) * 60 * 5
Me.TimerInterval = lngInterval
End Sub

Private Sub Form_Timer()
Dim dTimeStart As Date
Dim dTimeEnd As Date

dTimeStart = #3:00:00 PM#
dTimeEnd = #3:05:00 PM#
If Time >= dTimeStart And Time < dTimeEnd Then
    MsgBox "Got here"
End If

End Sub

HTH

Peter
 

EdFred

knows enough, dangerous
Local time
Today, 08:25
Joined
Mar 2, 2007
Messages
129
Peters way looks like it would work better than mine. I needed to keep track of the last time I perfomed the action, so I had to write that record to a table, but the thought process was the same. Just make sure you narrow your time range enough so that you don't keep getting a message box every 5 minutes. That could get annoying. :)
 

adam12

Registered User.
Local time
Today, 08:25
Joined
Mar 2, 2007
Messages
10
Ok all, thanks so much for your help. Here's what I came up with and it works great. OnTimer with 1000 milliseconds set:

If Time = #08:00:00 AM# Then
Msgbox "Send Report to Department", vbOkonly, "Send Report Confirmation"
End If

Thanks again for all your help.
 

Users who are viewing this thread

Top Bottom