Background color based on condition

E

Eric Blitzer

I have a continuous form and want to change the backcolor
of a field in one column based on a condition in another
column. My problem is that when the field is clicked the
backcolor that is appropiate is applied to the whole column
not just that one record. Here is my code

Private Sub Form_Current()
Dim lngYellow As Long, lngWhite As Long
lngYellow = RGB(255, 255, 0)
lngWhite = RGB(255, 255, 255)
If Me.ChATimeIn = 0 Or IsNull(ChATimeIn) Then
Me!ATimeIn.BackColor = lngWhite
Else
Me!ATimeIn.BackColor = lngYellow
End If

Thanks

Eric
 
A

Allen Browne

As you found, you cannot use the events to do this, as it applies to the
entire column.

If this is Access 2000 or later, use conditional formatting.
(On the Format menu in form design view.)
 
L

Lynn Trapp

Unfortunately, that's the way it is with a continuous form. In your specific
instance there is really only one ChATimeIn, but the form displays it
multiple times. However, not to fear. MVP Steven Lebans has created a way
around it. Check out the following website:

http://www.lebans.com/formatbycriteria.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top