If then MsgBox

T

Todd Huttenstine

On Userform1, I have TextBox1. I am trying to acheive the following... If
when the user clicks CommandButton1 and Textbox1 equals "" or "Enter Stat
Name here", then I would like a message box to popup telling the user
"INVALID DATA". If when the user clicks CommandButton1 and Textbox1 does
not equal "" or "Enter Stat Name here", then I would like the code to
continue to the next part of the code which would be the message box saying
"Are you sure?" Right now I am getting errors in the first messagebox.

Below is what I have so far?

Private Sub CommandButton1_Click()
If TextBox1.Value = "" Or "Enter Stat Name here" Then
MsgBox("Invalid Data", vbOKOnly) = vbOKOnly
Else
End If
If MsgBox("Are you sure?", vbYesNo) = vbNo Then
Exit Sub
End If
End Sub

Thanx
Todd Huttenstine
 
J

J.E. McGimpsey

One way:

Private Sub CommandButton1_Click()
With TextBox1
If .Value = "" Or .Value = "Enter Stat Name here"
MsgBox("Invalid Data", vbOKOnly)
Exit Sub
End If
End With
If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub
'vbYes, so do something...
End Sub
 
T

Todd Huttenstine

Thanx, that worked.

Todd


J.E. McGimpsey said:
One way:

Private Sub CommandButton1_Click()
With TextBox1
If .Value = "" Or .Value = "Enter Stat Name here"
MsgBox("Invalid Data", vbOKOnly)
Exit Sub
End If
End With
If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub
'vbYes, so do something...
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top