Change text box color when a number value changes

G

George

I would like to change a text color (on a Report) when the
the dollar value is < then 0.
I am able to code a form, but am not able to use the same
VB code on a report.
VB code used on a form:
If (me!Name)<0 then
me!Name.forecolor =255
Else
me!Name.forecolor =0
End If

Thanks for your Help!

George
 
F

Fons Ponsioen

Hi George.
Why not use the conditional formatting function in the
repoert design, This allows you set background or text
color depending on multiple condition s
Hope this helps.
Fons
 
F

fredg

I would like to change a text color (on a Report) when the
the dollar value is < then 0.
I am able to code a form, but am not able to use the same
VB code on a report.
VB code used on a form:
If (me!Name)<0 then
me!Name.forecolor =255
Else
me!Name.forecolor =0
End If

Thanks for your Help!

George

Happily enough, there is no coding needed.
Set the controls Format property to:
# [Black];-# [Red];0 [Black]

See Access Help
Format Property + Number and Currency datatypes

Also, if you really do have a field named 'Name', I would strongly
suggest you change it to something else.
"Name" like many other words, is an Access/VBA reserved word and
should not be used as a field name.

See the appropriate Microsoft KnowledgeBase article.

109312 'Reserved Words in Microsoft Access'
209187 'Acc2000: 'Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
 
Top