Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get different coloured text for records

Access Howto:

How do I get different coloured text for records

by  Frink  Posted    (Edited  )
If you have a field [strStatus] in a table which can have values of "On" or "Off", and you want "Off" records to appear in [color red]Red[/color] text and "On" records to have [color green]Green[/color] text, this is the FAQ for you.
Unfortunately, these values cannot be edited.

Make several copies of the field you want coloured, give them all the same size and position. Give them sensible names, like txtStatusOn, txtStatusOff. Make each one transparent, with a foreground colour set to the colour you want. You might want to make the fields disabled and locked.
In each controls Control Source put:
Code:
=IIf([strStatus]="On",[strStatus],"")
for the [color green]Green[/color] one, and
Code:
=IIf([strStatus]<>"On",[strStatus],"")
for the [color red]Red[/color] one.
These field will be empty unless the IIf expression is True, in which case it would appear as the text in the required colour.

Now open the form. All Status fields with a status of On will be in [color green]Green[/color] text, and all others will be in [color red]Red[/color].

Hope that makes your forms prettier,


- Frink
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top