hmm, Interesting...
Put this into the Tag property of the control.
NotNull
And put this into a module:
Function frm_CheckNull(frm As Form, blnSetColor)
Dim ctl As Control
Dim strName As String
Dim varTag As Variant
Dim blnCheckNull As Boolean
On Error GoTo err_frm_CheckNull
blnCheckNull = True
'loop through all controls on form and check if the control has a
'not null tag. IF it does, then check if control value is blank
'if it is blank, then set background color to red and inform user.
'It also sets the background color to white and black on all controls
'so they are updated when user enters data.
'Also, pass result back to calling program.
For Each ctl In frm.Controls
If ctl.ControlType = acComboBox Or ctl.ControlType = acTextBox Then
strName = ctl.name
varTag = ctl.Tag
If varTag Like "*NotNull*" Then
If blnSetColor = True Then
ctl.BackColor = vbWhite
ctl.ForeColor = vbBlack
End If
If IsNull(frm(strName)) Or Len(frm(strName)) = 0 Then
blnCheckNull = False
If blnSetColor = True Then
ctl.BackColor = vbRed
ctl.ForeColor = vbWhite
End If
End If
End If
End If
Next ctl
frm_CheckNull = blnCheckNull
exit_frm_CheckNull:
Exit Function
err_frm_CheckNull:
MsgBox "Calling Routine: basForms.frm_CheckNull" & vbCrLf & vbCrLf & "Error Code: " & Err.Number & vbCrLf & vbCrLf & "Error Description: " & CStr(Err.Description), vbCritical
Resume exit_frm_CheckNull
End Function
junior1544@jmjpc.net
Life is change. To deny change is to deny life.