Textbox Validation and Associated Checkbox
Hi, I have a checkbox for "N/A" and a textbox for storing input.
I have the following code checking to make sure the textbox stores a numeric
input:
Private Sub TextBox2_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If IsNumeric(TextBox2.Value) Then
ErrOmTxt = TextBox2.Value
Cancel = False
Else
MsgBox "Errors and Omissions value must be numeric. Please check
and re-enter, or check N/A for no coverage."
TextBox2.Value = ""
TextBox2.SetFocus
Cancel = True
End If
Exit Sub
End Sub
Basically, if the data is valid, store it in a String variable. Otherwise,
clear the textbox, and allow the user to enter a new value or to check the
checkbox. Checking the N/A checkbox will set Textbox2.Enabled = False
However, in testing--when I type in alpha characters, my msgbox will pop up,
but I cannot proceed to check the checkbox. I get stuck at this step until I
close the userform.
Any ideas?
Thanks in advance.
|