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

Conditional colour formatting cells

Status
Not open for further replies.
Apr 3, 2002
25
FR
I am trying to use an If statement to change the background colour of cells in a crosstab query based on the values of the column and row headings. I have written something like this but it just isn't working.

if {column a} = "1" then
if {row 1} = "a" then crRed
else
if {row 2} = "b" then crGreen
else crRed
else
if {column b} = "2" then
if {row 1} = "a" then crRed
else
if {row 2} = "b" then crGreen
else crGreen

Basically it won't change the colours depending on the headings, it just formats all the cells in the first colour in the statement.

Is there another function that will do this?
Cheers
Gaz
 
Try this

WhilePrintingRecords;

if {column a} = "1" and {row 2} = "b" then
crGreen
else if {column a} = "1" then
crRed
else if {column b} = "2" and {row 1} = "a" then
crRed
else if {column b} = "2" then
crGreen
else crNoColor //a catch-all if above conditions don't fit

I do think your tests are funny but perhaps you made it simplified...hope this helps

Jim Broadbent
 
It just sets all background colours to no colour.

I have written the same formula to determine the content of the cells and that works fine, but for some reason will not change the background colour.
 
It's only possible to apply a condition to a cross tab cell based on current field values. You can't base formatting on the value of a separate field in the report.

Naith
 
Sorry I didn't see the reference to "crosstab" in your post. I avoid using crosstab reports, prefering to write my own rather than using the CR crosstab wizard Jim Broadbent
 
I figured it out. You have to use the GridRowColumnValue function to determine the column and row headings.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top