PC Review


Reply
Thread Tools Rate Thread

on activate event

 
 
=?Utf-8?B?Q2Fyb2wgU2h1?=
Guest
Posts: n/a
 
      25th Sep 2007
question: this on activate event works great, but when it is morning hours,
it show "good evening", then in the evening hours it show "good morning",
can't figure out why, please help.

Private Sub Form_Activate()
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
 
Reply With Quote
 
 
 
 
Carl Rapson
Guest
Posts: n/a
 
      25th Sep 2007
"Carol Shu" <(E-Mail Removed)> wrote in message
news:8CBF37EE-4B24-4392-B76A-(E-Mail Removed)...
> question: this on activate event works great, but when it is morning
> hours,
> it show "good evening", then in the evening hours it show "good morning",
> can't figure out why, please help.
>
> Private Sub Form_Activate()
> 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


I'm not sure what you're trying to do with the Time() function, but as far
as I can tell it returns the actual time of day, not a number between 0 and
1. I'd suggest doing something like this:

If Hour(Time()) <= 12 Then
' morning
Elseif Hour(Time()) > 12 And Hour(Time()) < 18 Then
' afternoon
Else
' evening
End If

Carl Rapson


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FORM ACTIVATE EVENT Glint Microsoft Access Form Coding 3 10th Sep 2008 04:27 PM
On activate event =?Utf-8?B?U0hJUFA=?= Microsoft Excel Programming 5 30th Dec 2005 04:43 PM
activate event not fired ? ? =?Utf-8?B?anVzdHN0YXJ0ZXI=?= Microsoft VB .NET 5 5th Oct 2004 09:20 AM
activate event Cyrus Microsoft Dot NET Framework Forms 0 10th Dec 2003 02:15 AM
Activate event Lynn Microsoft Excel Programming 2 13th Sep 2003 09:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:04 PM.