change font colour on reports

D

dogfish

Howdy, i would like a traffic light system on TOTAL_PERCENT so if the result
is between 0 and 56 the colour will be red etc. i have this code on the open
action of the report but it comes up with a compile error else without if.

Please help i am not a code monkey, please help.

If Me.TOTAL_PERCENT >= 0 < 56 Then fontcolour = 255
ElseIf Me.TOTAL_PERCENT >= 57 < 64 Then fontcolour = 39423
ElseIf Me.TOTAL_PERCENT >= 65 < 100 Then fontcolour = 65280
End If
End If
End If
 
D

Dennis

If Me.TOTAL_PERCENT >= 0 And Me.TOTAL_PERCENT < 56 Then fontcolour = 255
ElseIf Me.TOTAL_PERCENT >= 57 And Me.TOTAL_PERCENT < 64 Then fontcolour
= 39423
ElseIf Me.TOTAL_PERCENT >= 65 And Me.TOTAL_PERCENT < 100 Then
fontcolour = 65280
End If
End If
End If
 
F

fredg

Howdy, i would like a traffic light system on TOTAL_PERCENT so if the result
is between 0 and 56 the colour will be red etc. i have this code on the open
action of the report but it comes up with a compile error else without if.

Please help i am not a code monkey, please help.

If Me.TOTAL_PERCENT >= 0 < 56 Then fontcolour = 255
ElseIf Me.TOTAL_PERCENT >= 57 < 64 Then fontcolour = 39423
ElseIf Me.TOTAL_PERCENT >= 65 < 100 Then fontcolour = 65280
End If
End If
End If


You must identify the controls correct property...
You must use the correct event.
You need to correctly write the code.

It is the Control's ForeColor property (not a non-existent FontColor
property) you want to change.

Place the code in whatever section the control is in Format event,
i.e. if the control is in the detail section, place the following in
the Detail Format event (NOT in the Open event).


If Me!TOTAL_PERCENT >= 0 and Me!Total_Percent < 56 Then
Me!Total_Percent.ForeColor = 255
ElseIf Me!TOTAL_PERCENT >= 57 and Me!Total_Percent < 64 Then
Me!Total_Percent ForColor = 39423
Else
Me!Total_Percent.ForeColor = 6528
End If

If you are using Access 2000 or newer, why don't you just use the
control's Conditional Formatting property instead?
 
Top