Message Box Question
Is Greeting the name of the ComboBox? If so:
Private Sub Greeting_Click()
If Me.Engineer_2.Value = "Steve" Then
If Time < 0.5 Then
Msg = "Morning"
ElseIf Time < 0.75 Then
Msg -"Afternoon"
Else
Msg -"Evening"
End If
Msg = Msg & "Good" & Me.Engineer_2.Value
MsgBox Msg
End If
End Sub
I did not see how you are trying to trigger the procedure in any of the
postings. Also,
This line:
Msg = Msg & "Good" & Me.Engineer_2.Value
Would make more sense like:
Msg = "Good" & Msg & Me.Engineer_2.Value
Also, the first If statement appears to require a manual change each time to
make it equate to true. You could change it to:
If Me.Engineer_2.ListIndex < -1 Then
That way it would execute if any name is selected and then the Msg part
would add the name in.
"Brian" wrote in message
...
Here is the code. I can't get it to open when the name 'Steve" is choosen
in
the User Form. I broke it again.
'Time Greeting
Private Sub Greeting()
If Me.Engineer_2.Value = "Steve" Then
If Time < 0.5 Then
Msg = "Morning"
ElseIf Time < 0.75 Then
Msg -"Afternoon"
Else
Msg -"Evening"
End If
Msg = Msg & "Good" & Me.Engineer_2.Value
MsgBox Msg
End If
End Sub
"Rick Rothstein" wrote:
Just concatenate it onto the greeting. If you are using my structure,
that
would look like this...
If Me.Engineer_2.Value = "Name" Then
If Time < 0.5 Then
Msg = "Morning"
ElseIf Time < 0.75 Then
Msg -"Afternoon"
Else
Msg -"Evening"
End If
Msg = Msg & " " & Me.Engineer_2.Value
MsgBox Msg
End If
--
Rick (MVP - Excel)
"Brian" wrote in message
...
How do I get the Message to use the Input from Engineer_2 on the user
form?
Where would I put that in the code?
"Brian" wrote:
I have a User Form that has a Combo Box in it. I would like for it to
greet
the user by name based on the time of day.
I have tried several variations of this code, but no luck as of yet.
Private Sub Greeting()
'Time Greeting
If Me.Engineer_2.Value = "Name" Then MsgBox
If Time < 0.5 Then Msg = "Morning" Else
If Time = 0.5 And Time < 0.75 Then Msg -"Afternoon" Else
If Time 0.75 Then Msg -"Evening"
MsgBox "Good" & Msg
End Sub
What am I doing wrong?
.
|