Solved Is there a better option for VBA to change background color

donkey9972

Registered User.
Local time
Today, 13:50
Joined
May 18, 2008
Messages
42
Hi,

I am trying to change the background color of the unbound field on the form I have which I have successfully done using the following code:

Code:
Private Sub txtFirstName_Exit(Cancel As Integer)
If IsNull(txtFirstName) Then
    Me.txtFirstName.BackColor = vbRed
Else
    Me.txtFirstName.BackColor = vbWhite
End If
End Sub

My issue is I have 5 fields I need to do this for, is there a better option to do this other than running this code in the "on exit" for each field?
 
I am not familiar with using conditional formatting just to determine if anything is entered into the field let alone 5 fields. Are you talking about using VBA as conditional formatting or the point and click conditional formatting?
 
You can use the "point and click" conditional formating:
1731487765277.png
 
Using the same type of conditional formatting I found that using expression is with IsNull(txtfirstname.Value) in the field for it works exactly how I was wanting.
 

Users who are viewing this thread

Back
Top Bottom