I would write a generic sub that would check the textbox for null and
highlight red if it was null or white (normal) if it wasn't
Private Sub HighlightTextBox(txtBox As TextBox)
If IsNull(txtBox.Value) Then
'if the field is null - back color red
txtBox.BackColor = vbRed
Else
'otherwise white
txtBox.BackColor = vbWhite
End If
End Sub
I would then have some code in the open/load event for the form that
would loop through the text boxes you wanted to check for null like so;
Private Sub Form_Load()
Dim ctl As Control
Dim ctls As Controls
Set ctls = Me.Form.Controls
For Each ctl In ctls
'Loop through each control at startup to set the initial
highlighting
If ctl.ControlType = 109 Then
'Only validate textboxes this way
'you might want to specify which textboxes
'or have different validation for other controls
HighlightTextBox ctl
End If
Next ctl
End Sub
Finally I would have call the sub again from each relevent text boxes
lost focus event - this would remove the highlighting if the textbox
had a value. E.g.
Private Sub txtBox1_LostFocus()
'the lost focus event of each control should also call the
validation procedure
HighlightTextBox txtBox1
End Sub