Change font color in a report field

  • Thread starter Thread starter galsaba
  • Start date Start date
G

galsaba

How can I change the font color based on the value?
for example, say I have a field "age". Whenever the value is more than
50 I want that the data (age) will be in red fonts . Otherwise - black
fonts.

Thanks,

galsaba
 
How can I change the font color based on the value?
for example, say I have a field "age". Whenever the value is more than
50 I want that the data (age) will be in red fonts . Otherwise - black
fonts.

Thanks,

galsaba

Always post your Access Version number and also where you wish to do
this:in a Form, Query, or Report?

If you are using Access 97 post back with the above information.

Do you have Access 2000 or newer?
In a Form or Report, use the control's Conditional Formatting.
Select the control.
Click on Format + Conditional formatting

In a query or table, forget about it!
 
Hi there,
You will need to use the 'On Format' event of the section of the report
where the age control is located.
The code might look something like this:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If txtAge > 50 Then
txtAge.ForeColor = 255 'red
Else
txtAge.ForeColor = 0 ' black
End If

End Sub

Hope this helps.

Lee
 
Back
Top