Background color based on condition

  • Thread starter Thread starter Eric Blitzer
  • Start date Start date
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
 
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.)
 
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
 
Back
Top