T
Tom
I have a form with SUBMIT button. When clicked the form checks whether or
not any controls are left blank. If yes, all blank controls are highlighted
in yellow and nothing happens (as intended).
Now, however, I need to exclude some "required" controls from the ForLoop.
Completing them or leaving them empty should be optional.
I attempted to set the tag property to "R" (Required) and "NR" (Not
Required).
Including the (pseudo) "IF = R" into the ForLoop didn't seem to work. Does
anyone know of the right syntax for know of another approach that will
highlight only certain fields?
Thanks,
Tom
===================
Private Sub btnSubmit_Click()
'Declare variables
Dim ctl As Control
Dim NotCompleted As String
'Validation procedure to determine unselected combos and blank textboxes
NotCompleted = False
For Each ctl In Me.Controls
If IsNull(ctl) Then
NotCompleted = True
ctl.SetFocus
ctl.BackColor = vbYellow
End If
Next ctl
If NotCompleted = True Then
MsgBox "You must complete all fields!", vbInformation, "Missing
Data"
Else
'other stuff... such as INSERT statement
End If
End Sub
===================
not any controls are left blank. If yes, all blank controls are highlighted
in yellow and nothing happens (as intended).
Now, however, I need to exclude some "required" controls from the ForLoop.
Completing them or leaving them empty should be optional.
I attempted to set the tag property to "R" (Required) and "NR" (Not
Required).
Including the (pseudo) "IF = R" into the ForLoop didn't seem to work. Does
anyone know of the right syntax for know of another approach that will
highlight only certain fields?
Thanks,
Tom
===================
Private Sub btnSubmit_Click()
'Declare variables
Dim ctl As Control
Dim NotCompleted As String
'Validation procedure to determine unselected combos and blank textboxes
NotCompleted = False
For Each ctl In Me.Controls
If IsNull(ctl) Then
NotCompleted = True
ctl.SetFocus
ctl.BackColor = vbYellow
End If
Next ctl
If NotCompleted = True Then
MsgBox "You must complete all fields!", vbInformation, "Missing
Data"
Else
'other stuff... such as INSERT statement
End If
End Sub
===================