Modal Welcome Message Access 2007 - VBA code not working

TheGeneral

New member
Local time
Today, 00:53
Joined
Aug 26, 2011
Messages
8
Hi Everyone,

totaly new to forums so forgive me if i have foregone any relevant courtesies!

I am building a database and have decided to add a Modal pop-up welcome message which i hoped would say good morning/afternoon/evening depending on the relevant time of day.

I have added 3 lables;

LblMorning
LblAfternoon
LblEvening

each with the relevant caption;
Good Morning
Good Afternoon
Good Evening.

The labels are set to Not visible so the code i have added will set the relevant label to visible.

I have applied code to the "On Activation" event as follows;

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 LblClock > 0.75 Then
[LblMorning].Visible = False
[LblAfternoon].Visible = False
[LblEvening].Visible = True

End If

End Sub

However this is not working and i cant see the issue in the code. at present when this modal opens it doesnt display any of my labels.

Would really appreciate any help anyone can give on this!

Thanks everyone!
 
Just at first glance... I would have the final else be just a plain else and not an elseif... else no condition might ring true.
 
Thanks RuralGuy! moved this to on load and is working!

I will check and see that this is working correctly when it should change over to "good Evening" and if that doesnt change i will amend the Else if part.

Thanks again guys! greatly appreciated!
 
What a great idea, I just copied and pasted the following code:
Private Sub Form_Load()
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 LblClock > 0.75 Then
[LblMorning].Visible = False
[lblAfternoon].Visible = False
[LblEvening].Visible = True

End If

End Sub

But I received an error: See attach

Thanks
 

Attachments

I just retype the ElseIf and now it works without any error. You mean I fix something on my own................. wow
 
I wonder what the users think about this - it's like getting to some website and getting a flash splash thingy for 30 seconds before being able to do what one came to do. Well, at least a modal form presumably has a close button ...that the user HAS to click on, unless this thing disappears on its own accord after a sec or two.
 

Users who are viewing this thread

Back
Top Bottom