Conditional Formatting with VBA

morlan

Registered User.
Local time
Today, 22:24
Joined
Apr 23, 2003
Messages
143
Report: Changing the colour of a control depending on its value.

Hi,

I have a report based on a query. I want to change the colour of the controls background depending on its value. Here is a sample of the query:

Venue - Rejected
London - 1.00
Glasgow - 1.50
Bristol - 2.10


Anything above 2.00 should have a red background.

Can I do something like :

If me.Rejected.value => 2.00 then
me.Rejected.BackgroundColour = 'Red'
End if

Do Access Reports support these methods?
 
Try changing the background color on the report OnFormat event.
 
if it's access 2000 or later, you can use conditional formatting

if it's 97, you might want to try the format event for whichever section that it's in (detail, footer etc)
 
chris_dono said:
if it's access 2000 or later, you can use conditional formatting

if it's 97, you might want to try the format event for whichever section that it's in (detail, footer etc)

Yeah, conditional formatting works fine but I need to do this in VBA.
 
In the Detail OnFormat event
If me.Rejected >= 2 Then
me.Rejected.BackgroundColour = vbRed
Else
me.Rejected.BackgroundColour = vbWhite
End if
 
morlan said:
Yeah, conditional formatting works fine but I need to do this in VBA.

your code is ok, just put it in the format event for whichever section of the report the controls are on
 

Users who are viewing this thread

Back
Top Bottom