Conditional Formatting (1997)

  • Thread starter Thread starter Jane
  • Start date Start date
J

Jane

Hi,

I am trying to replicate a feature that I used to use in
Excel.

I have a report on a cross tab query and I would like the
formatting of the backround to depend on the result.
For example, if the result is less than 5 then the
background will be red, but if it is more then it will be
green.
I have looked around but cannot find my answer, please
please help.

Thanks

J
 
Jane:

By saying in your message title (1997) does that mean that you are using
Access 97?

Either way, you can do the formatting you want by adding VBA code like the
following to your report's On Print Event of the Detail section:

If Me!YourControlToEvaluate.Value < 5 Then
'Not clear whether you wanted the section backgroud _
or control background to be coloured but here's both _

Me.Section(0).backcolor = 255 'section background
Me!YourControlToEvaluate.backcolor = 255 'red
Else
Me.Section(0).backcolor = 4259584 'lime green
Me!YourControlToEvaluate.backcolor = 4259584
End if

You can get the color values by using the properties dialog for the control
or section and choosing a color and then looking at the value of the
backcolor property. White = 16777215

HTH
 
Back
Top