folkstorm
05-24-2017, 11:16 AM
I have user form with 1 combobox field and several text fields. Combobox 1 = type of application (7 different results) Text field like Name, Surname, Town, Post Code etc.
After pressing Ok button, I would like prompt user if mandatory field is missing.
Mandatory field for 1 selection is field 1, field2 and field3 for selection 2 only filed 1 and 2 for 3 only field 6 etc.
Weird thing is that if I select something I didn't define in this sub, I selecting value 4 or 5 I still get message. What did I miss?
Private Sub CommandButton1_Click()
If UserForm2.ComboBox1T.Value = "1.New Application" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Or TextBox3.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
If UserForm2.ComboBox1T.Value = "2.Old Application" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
If UserForm2.ComboBox1T.Value = "3.Somethingelse" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
After pressing Ok button, I would like prompt user if mandatory field is missing.
Mandatory field for 1 selection is field 1, field2 and field3 for selection 2 only filed 1 and 2 for 3 only field 6 etc.
Weird thing is that if I select something I didn't define in this sub, I selecting value 4 or 5 I still get message. What did I miss?
Private Sub CommandButton1_Click()
If UserForm2.ComboBox1T.Value = "1.New Application" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Or TextBox3.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
If UserForm2.ComboBox1T.Value = "2.Old Application" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
If UserForm2.ComboBox1T.Value = "3.Somethingelse" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If