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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change color of field based on its contents

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
0
0
US
Hi!

I am creating a new report in MS Access 2002. When I print my report, I want the color of a field to change based upon the value of that field.

Here are some details on this issue. The field, which is called "ID code", will always have one of 16 values. The values will be repeated in the report. It is a text field. Seven of the values correspond to blue, one corresponds to gold, and the eight others correspond to green. I just want to change the color of THIS field, not the other fields in the detail band.

Here are some things that I already know. I know that the text box's font color is controlled by a property called "fore color". I know that that color is expressed as a number (for example, black is zero). I know that I can put VB code in my detail band. And, I know that I can create a lookup table with the ID codes and the matching color names as text. And, I know that I can set a relationship between my main table and my lookup table (based on ID code). And, I know that I can create an invisible field with that color name. So I need to write a little piece of code that says something like...

do case

case invisible field="blue"
make ID code fore color property = some number equating to blue

case invisible field="black"
make ID code fore color property= 0

end case

The problem is that I don't really know how to write that code :(

Can anyone out there get me started?

OhioSteve
 
Can't you just use Conditional Formatting?

From the toolbar: Format - Conditional Formatting
 
I was not aware of conditional formatting before reading your response.

Since then I have investigated the feature, and it meets most of my needs. Actually, I have two fields that I need to alter. The other fields has five variations, not three. CF allows at the most four variations. However, I can make two reports to compensate for this.

I cannot see where the CA interface writes instructions. It would be nice to see that so I could further customize it.
 
Thanks for your help! If anyone else has suggestions, fire away!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top