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 Chriss Miller 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 background colours for records

Access Howto:

How do I get different background colours for records

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

Make a tabular form based on the table, and make all the backgrounds to the fields in the detail section transparent.
Now create a text field which covers the whole of the detail section. Make it font WebDings, Foreground colour [color red]Red[/color], Disabled and Locked. Make it's background transparent and select 'Move To Back'
In its Control Source put:
Code:
=IIf([strStatus]="Off",String$(20,"g"),"")
This field will be empty unless strStatus="Off", in which case it would be a string of 20 WebDings g characters, which happen to be a solid block.
Create another identical field, but this time make it [color green]Green[/color] and its Control Source should be:
Code:
=IIf([strStatus]="On",String$(20,"g"),"")
Now open the form. All records with a status of Off will have a [color red]Red[/color] background, and all records with a status of On will have a [color green]Green[/color] background.

If the coloured bar is not high enough then increase the font size.
If the coloured bar is too short then increase the '20' in the Control Sources.
If the coloured bar does not look like a coloured bar then replace the 'g' in the control sources with an alternative letter and change the font to something more appropriate. A good way to find the character to use is by using Insert Symbol in Word.

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