I have a form that has several text boxes and combo boxes. I need to validate that the text boxes and combo boxes have values in them before using the data to populate a table in SQL.
For the text boxes I found this, which does check to see if they are empty. But if the user just skips to the next text box the user still can click on the save button and the data or lack of goes into the SQL table.
Any way to keep the user from clicking on the save button unless all the text boxes have text and combo boxes have something selected?
TIA
For the text boxes I found this, which does check to see if they are empty. But if the user just skips to the next text box the user still can click on the save button and the data or lack of goes into the SQL table.
Code:
Private Sub TextBox3_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox3.Validated
Me.ErrorProvider1.SetError(TextBox3, "")
End Sub
Private Sub TextBox3_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox3.Validating
Try
If Me.TextBox3.Text.Length = 0 Then
Me.ErrorProvider1.SetError(Me.TextBox3, "Please Enter a value")
Throw New Exception("Please enter a value")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Any way to keep the user from clicking on the save button unless all the text boxes have text and combo boxes have something selected?
TIA