I've been reading up on how to use validation on forms.
I need to validate a field has been filled in so I have
used the 'Validating' event that is called just before my form textbox loses focus.
If the field is blank, the focus stays on the textbox and an
appropriate error message is displayed.
The problem is that if a user clicks the 'exit' button i do not want the focus to be returned to the textbox, even if it is not filled in.
According to everything I have read, I can bypass the validating event on my textbox by setting the 'CausesValidation' property on my Exit button to false
at design time.
The rouble is, it doesn't have any effect.
If my textbox is blank and I click on my exit button to close the form, the validation keeps me on the textbox control.
Anybody any idea where I'm going wrong?
Private Sub MyTextBox_Validating(ByVal sender As Object _
ByVal e As System.ComponentMode1.cancelEventArgs) _
handles MyTextBox.Validating
If MyTextBox.text = "" Then
e.cancel = true
End if
End Sub
I need to validate a field has been filled in so I have
used the 'Validating' event that is called just before my form textbox loses focus.
If the field is blank, the focus stays on the textbox and an
appropriate error message is displayed.
The problem is that if a user clicks the 'exit' button i do not want the focus to be returned to the textbox, even if it is not filled in.
According to everything I have read, I can bypass the validating event on my textbox by setting the 'CausesValidation' property on my Exit button to false
at design time.
The rouble is, it doesn't have any effect.
If my textbox is blank and I click on my exit button to close the form, the validation keeps me on the textbox control.
Anybody any idea where I'm going wrong?
Private Sub MyTextBox_Validating(ByVal sender As Object _
ByVal e As System.ComponentMode1.cancelEventArgs) _
handles MyTextBox.Validating
If MyTextBox.text = "" Then
e.cancel = true
End if
End Sub