excel vb form - creating error message

  • Thread starter Thread starter Nilz-p
  • Start date Start date
N

Nilz-p

hhhhhhhhhheeeeeeeeeeelllllllllppppppppp bbbbbbbblllllllaaaaaaadddd
...............

ON my form i got test boxes .... the text in the text boxes ge
submited by a command botton to a sheet.....

if 1 or more text boxes are empty i want it to display an error messag
when the command botton is clicked....

message should be like this
eg "oh sh*t you missed 1"


thanx and saf
 
Private Sub CommandButton1_Click()

If TextBox1.Value = "" Then
MsgBox "You must fill in text box 1.", _
vbInformation, "Missing Information"
TextBox1.SetFocus
ElseIf TextBox2.Value = "" Then
MsgBox "You must fill in text box 2.", _
vbInformation, "Missing Information"
TextBox2.SetFocus
Else
'put the text into the cells on the sheet
End If

End Sub
 
Nils;

Sub ResetTextBoxes()
Dim ctrl As Control
For Each ctrl In UserForm1.Controls
If TypeName(ctrl) = "" Then
Msgbox "Empty Textbox"
End If
Next ctrl
End Sub

Mark.
 

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

Back
Top