By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,254 Members | 2,386 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,254 IT Pros & Developers. It's quick & easy.

Timed Messages

P: n/a
Hi All

Got a great code that displays Good Morning / Good Afternoon / Good Evening
depending on the system time from:

http://www.microsoft-accesssolutions...me_message.htm

Looks great and the idea is brill - however it keeps displaying "Good
Evening" = regardless of the time.

The code is:

If Time() < 0.5 Then
[lblMorning].Visible = True
[lblAfternoon].Visible = False
[lblEvening].Visible = False

ElseIf Time() > 0.5 And Time() < 0.75 Then
[lblMorning].Visible = False
[lblAfternoon].Visible = True
[lblEvening].Visible = False

ElseIf Time() > 0.75 Then
[lblMorning].Visible = False
[lblAfternoon].Visible = False
[lblEvening].Visible = True
End If
End Sub

Anyone help??

Thanks

Steve
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Steve Patrick" <sp********@blueyonder.co.uk> wrote:
Got a great code that displays Good Morning / Good Afternoon / Good
Evening depending on the system time from:

http://www.microsoft-accesssolutions...me_message.htm

Looks great and the idea is brill - however it keeps displaying "Good
Evening" = regardless of the time.


Hi Steve,

I've seen some junk in my time but that takes the biscuit! You need only
one label and set it's 'caption' property accordingly, summat like (not
tested):

Dim varTime As Variant, strLegend As String

varTime = Time()
If varTime > "00:00:01" And varTime < "12:00" Then strLegend = "Good
Morning"
If varTime >= "12:00" And varTime < "18:00" Then strLegend = "Good
Afternoon"
If varTime >= "18:00" And varTime < "23:59" Then strLegend = "Good Evening"
Me.lblGreeting.Caption = strLegend

Regards,
Keith.
Nov 13 '05 #2

P: n/a
this works... ugly, but it works. (Kinda like me... ugly, but I have a pulse...)

Private Sub Command6_Click()
Dim lngHours As Integer
lngHours = DatePart("h", Me.txtTime)
Select Case lngHours
Case Is < 12
Me.txtGreeting = "Morning"
Case 12 To 17
Me.txtGreeting = "Afternoon"
Case Else
Me.txtGreeting = "Evening"
End Select

End Sub
Nov 13 '05 #3

P: n/a
Thanks Keith

Somewhat of a newbie here - so I need some further help if poss.

Do I still need to creat 3 lables (or Text boxes)?

What goes into the caption line on properties of the lable lables?

Where does the code go - is it in the properties of the lable / lables
or of the form?

Sorry to be a pain - I will get the hang of t all at some point.

Steve


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4

P: n/a
Steve Patrick <st***********@blueyonder.co.uk> wrote:
Do I still need to creat 3 lables (or Text boxes)?
No, just one label is required called (for example) "lblGreeting".

What goes into the caption line on properties of the lable lables?
You can type whatever you want into the label's "Caption" property because
the code will overwrite it.

Where does the code go - is it in the properties of the lable / lables
or of the form?
The code goes in the "On Load" event of the form. Select the form's
properties and go to the Event tab. Click in the "On Load" property box
and select "Event procedure" from the drop-down, then click the button to
the right of the property box (it has 3 dots in it). Put the code between
"Private Sub Form_Load()" and "End Sub" - note that these need to be on
their own lines.

I'm assuming Access 97 here - compile the code using the menu item
Debug/Compile and save all ...
Sorry to be a pain - I will get the hang of t all at some point.


No problem :o)
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.