Say Good morning, Good afternoon! (1 Viewer)

Sohaila Taravati

Registered User
Joined
Oct 24, 2001
Messages
266
I have a form that when the user opens it up it recognizes their name. How can I make the form tell them Good morning or good afternoon Mr/Mrs Brown. I know I probably have to put a field on the form that =Time() and an If statement that by looking at the field would recognize if it is morning or afternoon. Can anybody help? Thank you in advance
 

Alexandre

Registered User
Joined
Feb 22, 2001
Messages
794
You do not necessarily need to place a control holding the time on your form. Checking for the current time in, for example, the on open event of your form should be enough:

If Time()> #12:00:00# then
Msgbox "Good Afternoon"
else
MsgBox "Good Morning"
End if

Alex

[This message has been edited by Alexandre (edited 02-21-2002).]
 

Graham T

Registered User
Joined
Mar 14, 2001
Messages
300
I created a form and included 3 labels that are displayed dependant on the time.

The labels used - lblMorning, contains the caption of "Good Morning"; lblAfternoon contains the caption of "Good Afternoon" and lblEvening contains "Good Evening" as the caption.

The code attached to the forms On_Activate event is as follows:

Private Sub Form_Activate()

'When the database is opened displays welcome user message.

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

This works fine and shows the greating directly on the form, rather than opening up a message box.

HTH

Graham

[This message has been edited by Graham T (edited 02-22-2002).]
 

ColinEssex

Old registered user
Joined
Feb 22, 2002
Messages
8,170
You could do a really fancy splash form with the appropriate text and hold it open for a few seconds using the timer, when the database is opened.

Colin
 

BukHix

Registered User
Joined
Feb 21, 2002
Messages
379
To get the username into the message you could do it whith something like this:

Code:
Dim strName
'set the variable to whatever control holds the username
strName = "BukHix"
'something like strName = txtUserName


If Time() > #12:00:00 PM# Then
    MsgBox "Good Afternoon" & " " & strName
Else
    MsgBox "Good Morning" & " " & strName
End If
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom