Change font color in a report field

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
 
F

fredg

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!
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top