I have a made a userform with 8 groups of 1 Combobox and 2 Textboxes.
I want to create required fields, so that if one of the input boxes within each group is filled in, the rest in that group must be filled in as well. Here is what I have coded:
'Group 1
If cmb1.Value <> "" And txt2.Value = "" Or txt2Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
If txt2.Value <> "" And cmb1.Value = "" Or txt2Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
If txt2Hd.Value <> "" And cmb1.Value = "" Or txt2Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
'Group 2
If cmb2.Value <> "" And txt3.Value = "" Or txt3Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
If txt3.Value <> "" And cmb2.Value = "" Or txt3Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
If txt3Hd.Value <> "" And cmb2.Value = "" Or txt3Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
With the "Group 1" code alone, my conditional required fields work (within that group). BUT when I introduce the "Group 2" code, even when all of Group 2 is filled out, I cannot enter the data. I get the msgbox "You must fill in all three Fields (Grower, Case and Harvest Date)"
Not Sure What Im doing Wrong. Please Help! Thanks
I want to create required fields, so that if one of the input boxes within each group is filled in, the rest in that group must be filled in as well. Here is what I have coded:
'Group 1
If cmb1.Value <> "" And txt2.Value = "" Or txt2Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
If txt2.Value <> "" And cmb1.Value = "" Or txt2Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
If txt2Hd.Value <> "" And cmb1.Value = "" Or txt2Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
'Group 2
If cmb2.Value <> "" And txt3.Value = "" Or txt3Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
If txt3.Value <> "" And cmb2.Value = "" Or txt3Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
If txt3Hd.Value <> "" And cmb2.Value = "" Or txt3Hd = "" Then
MsgBox " You must fill in all three Fields (Grower, Case and Harvest Date)"
Exit Sub
End If
With the "Group 1" code alone, my conditional required fields work (within that group). BUT when I introduce the "Group 2" code, even when all of Group 2 is filled out, I cannot enter the data. I get the msgbox "You must fill in all three Fields (Grower, Case and Harvest Date)"
Not Sure What Im doing Wrong. Please Help! Thanks