473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Timed Messages

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
4 2048
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Javaman59 | last post by:
I have a GUI which is monitoring a real-time device. I have several timed actions, such as periodic polling of the device, and indicators which flash for a fixed period. My first implementation...
1
by: benmorganpowell | last post by:
I have a small windows service which connects to a POP3 server at defined intervals, scans the available messages, extracts the required information and inserts the data into a SQL database. I am...
5
by: Sachin Surana | last post by:
We use HttpWebRequest to send the request at a URL. But some times the method GetResponse throws a time out exception. But when we check the IIS logs, there is no such entry. So the request never...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
3
by: sebnunes | last post by:
Hi all, I have a strange behavior with the ASP .NET 2.0 Admin tool. When I click on ASP.NET Configuration in VS 2005 the Administration intro page displays correctly but when I click on any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.