G
Guest
The code I have pasted below checks my form for values in all the fields and
gives me a message box. However, the message indicates which fields have been
filled in and I want to know which fields are NOT filled in.
Any suggestions?
Dim ctl As Control
Dim strMissedControls As String
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
If Len(ctl.Value & "") > 0 Then
strMissedControls = strMissedControls & vbCrLf & ctl.Name
End If
End If
Next ctl
If Len(strMissedControls) > 0 Then
MsgBox "You have not completed the following fields: " & strMissedControls
Cancel = True
End If
gives me a message box. However, the message indicates which fields have been
filled in and I want to know which fields are NOT filled in.
Any suggestions?
Dim ctl As Control
Dim strMissedControls As String
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
If Len(ctl.Value & "") > 0 Then
strMissedControls = strMissedControls & vbCrLf & ctl.Name
End If
End If
Next ctl
If Len(strMissedControls) > 0 Then
MsgBox "You have not completed the following fields: " & strMissedControls
Cancel = True
End If