Hi,
I need to validate my form so that when a user tries to insert a record, certain fields must be completed. If a field isn't filled, i need the label next to it to be highlighted red. I think i'm nearly there but it isnt working quite how i'd like.
At the mo, it does the first if, then skips the rest and goes to the msgbox part - i need it to loop round i think so that it goes through and checks all the fiellds before displaying the message and highlighting each's label red.
What do i need to do to get this working please?
Al
I need to validate my form so that when a user tries to insert a record, certain fields must be completed. If a field isn't filled, i need the label next to it to be highlighted red. I think i'm nearly there but it isnt working quite how i'd like.
At the mo, it does the first if, then skips the rest and goes to the msgbox part - i need it to loop round i think so that it goes through and checks all the fiellds before displaying the message and highlighting each's label red.
VB.NET:
Public Sub validateForm()
If Me.cboSupplier.SelectedValue = (0) Then
lblSupplier.ForeColor = System.Drawing.Color.Red
ElseIf cboMaterial.SelectedValue = (0) Then
lblPartNo.ForeColor = System.Drawing.Color.Red
ElseIf txtDefectDesc Is "" Then
lblDefectDesc.ForeColor = System.Drawing.Color.Red
ElseIf cboDefect.SelectedValue = (0) Then
lblDefect.ForeColor = System.Drawing.Color.Red
ElseIf cboAction.SelectedValue = (0) Then
lblAction.ForeColor = System.Drawing.Color.Red
End If
'MsgBox("The fields in red must be updated")
Exit Sub
End Sub
What do i need to do to get this working please?
Al