I have this code run behind my submit button to double check that all txt boxes and cbo's are filled in before submitting the data.
Code:
Dim c As Control
For Each c In Me.Controls
If c.ControlType = acTextBox Then
If IsNull(c.Value) Or c.Value = "" Then
MsgBox "Please fill the form to completion before submission.", vbOKOnly, "Missing Information"
Exit Sub
End If
If c.ControlType = acComboBox Then
If IsNull(c.Value) Or c.Value = "" Then
MsgBox "Please fill the form to completion before submission.", vbOKOnly, "Missing Information"
Exit Sub
End If
End If
End If
Next
However I get the error "Next without For"
EDIT: Updated code, all I did was add an extra 'End if' before the Next. Not sure why this worked but it did
The code works well for all null textboxes but does not catch if the combo boxes are null. Any ideas?