An easier way to check txtbxs and cmbobxs on a form for null or zero without going 5(?) deep?
Whew!
Thnks,
Doug.
Code:
Function ChkFlds(FormName As Form) As String
'Function ChkFlds checks each textbox and combobox control on the passed form object for
'null or zero values (zero values where applicable) and returns the control name with the
'lowest tab index of any control found on the form that's either null or zero...
Dim Msg, Title, Style
Dim LwstTbIndx As Single
LwstTbIndx = 1000000 'nobody puts a million controls on a form, right?
For Each ctl In FormName
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
If IsNull(ctl) Then GoTo lbl1
If ctl.Format = "General Number" Then
If ctl = 0 Then
lbl1: If ctl.TabIndex < LwstTbIndx Then
LwstTbIndx = ctl.TabIndex
ChkFlds = ctl.Name
End If
End If
End If
End If
Next ctl
If Len(ChkFlds) <> 0 Then
Msg = "At least one of the input fields on the form is blank or Zero." & (Chr(13) & Chr(10)) & _
"You must fill in all the input fields (or select an item from a" & (Chr(13) & Chr(10)) & _
"drop down list) before clicking on the 'Import' button."
Title = "Incomplete Form..."
Style = vbOKOnly
MsgBox Msg, Style, Title
End If
End Function
Whew!
Thnks,
Doug.
Last edited: