rockwellsba
Technical User
Hi. I have a few CheckBoxes and lots of TextBoxes in my UserForm. Upon user click of the CommandButton [OK], the routine checks the form so that all fields are filled-in. What I don't know how to do is to have the CheckBox be verified (verify that the user has put a check in the checkbox). Any assistance is very appreciated.
Here's my code:
Private Sub CommandButton1_Click()
'' Validate all TextBoxes
If TextBox1.Text = "" Then
MsgBox "Name Of Applicant field is not complete"
TextBox1.SetFocus
Exit Sub
End If
If TextBox2.Text = "" Then
MsgBox "Contact Name field is not complete"
TextBox2.SetFocus
Exit Sub
End If
If TextBox3.Text = "" Then
MsgBox "Applicant Phone field is not complete"
TextBox3.SetFocus
Exit Sub
End If
If TextBox4.Text = "" Then
MsgBox "Applicant Fax field is not complete"
TextBox4.SetFocus
Exit Sub
End If
If TextBox5.Text = "" Then
MsgBox "Applicant Address field is not complete"
TextBox5.SetFocus
Exit Sub
End If
'If we got here, textboxes have valid input
'Put valid inputs into document
With ActiveDocument
.Bookmarks("NameOfApplicant").Range _
.InsertBefore TextBox1.Text
.Bookmarks("ContactName").Range _
.InsertBefore TextBox2.Text
.Bookmarks("ApplicantPhone").Range _
.InsertBefore TextBox3.Text
.Bookmarks("ApplicantFax").Range _
.InsertBefore TextBox4.Text
.Bookmarks("ApplicantAddress").Range _
.InsertBefore TextBox5
End With
''We got this far, must be ready to close the dialog
Unload Me
'End If
End Sub
Here's my code:
Private Sub CommandButton1_Click()
'' Validate all TextBoxes
If TextBox1.Text = "" Then
MsgBox "Name Of Applicant field is not complete"
TextBox1.SetFocus
Exit Sub
End If
If TextBox2.Text = "" Then
MsgBox "Contact Name field is not complete"
TextBox2.SetFocus
Exit Sub
End If
If TextBox3.Text = "" Then
MsgBox "Applicant Phone field is not complete"
TextBox3.SetFocus
Exit Sub
End If
If TextBox4.Text = "" Then
MsgBox "Applicant Fax field is not complete"
TextBox4.SetFocus
Exit Sub
End If
If TextBox5.Text = "" Then
MsgBox "Applicant Address field is not complete"
TextBox5.SetFocus
Exit Sub
End If
'If we got here, textboxes have valid input
'Put valid inputs into document
With ActiveDocument
.Bookmarks("NameOfApplicant").Range _
.InsertBefore TextBox1.Text
.Bookmarks("ContactName").Range _
.InsertBefore TextBox2.Text
.Bookmarks("ApplicantPhone").Range _
.InsertBefore TextBox3.Text
.Bookmarks("ApplicantFax").Range _
.InsertBefore TextBox4.Text
.Bookmarks("ApplicantAddress").Range _
.InsertBefore TextBox5
End With
''We got this far, must be ready to close the dialog
Unload Me
'End If
End Sub