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!

Changing row colors within a cross-tab using a formula

Status
Not open for further replies.

jjk238

Programmer
Jan 16, 2003
14
0
0
US
I am trying to change the color of certain rows using this formula in Basic Syntax (Crystal 10):

If {sp_rpt_Car5000Q;1.ConActive} = FALSE Then
formula = crRed
Else
formula = crBlack
End If

I have used this formula in other reports to change row colors and it has worked fine. This is the first time that I am trying it in a cross-tab, and it hasn't been working at all. I have tried similar formulas as well with no luck.
 
You have to use gridrowcolumnvalue or currentfieldvalue in crosstab conditional formulas. What are your column and row fields and is {sp_rpt_Car5000Q;1.ConActive} one of them?

-LB
 
{sp_rpt_Car5000Q;1.ConActive} is a report field. It is not a column or a row. I had it as a column and it still did not work.
The row names are: {sp_rpt_Car5000Q;1.CarAName}, {sp_rpt_Car5000Q;1.CovDesc}, and @ConNameANDLocation - which is a formula concatenating CarAName and CarAddress.
The column is {sp_rpt_Car5000Q;1.BranchCode}.
The summarized field is {sp_rpt_Car5000Q;1.CovDesc}.

The report looks like this:

CarAName Coverage Contact-Address Branches
Colony Ins Property JJ Kelly-Pittsburgh PA IA MN
Greg G-Pittsburgh PA IA MN
Health JJ Kelly-Pittsburgh PA MN
Marc M-Pittsburgh IA
Essex Ins Property Ken G-Chicago IL


I hope that this explains it ok. Thanks for your help.
 
So how does {sp_rpt_Car5000Q;1.ConActive} relate to your crosstab column or row fields? I think you can only conditionally color by referencing columns/rows or currentfields, i.e., I think this field would have to be included in the crosstab.

-LB
 
I added {sp_rpt_Car5000Q;1.ConActive} as a row in the crosstab. I then tried the same formula that I have above and it did not work. I tried to use the gridrowcolumnvalue as you suggested, but it keeps saying that it wants a string, and ConActive is a boolean. Maybe my syntax is wrong:

If GridRowColumnValue({sp_rpt_Car5000Q;1.ConActive}) = True Then
formula = crRed
Else
formula = crBlue
End If

Any ideas?
 
It should be:

If GridRowColumnValue("sp_rpt_Car5000Q;1.ConActive") = True Then
formula = crRed
Else
formula = crBlue
End If

Remove the curly brackets and replace with quotes. If you want to change the row label also, then select that and use:

if currentfieldvalue = true then
formula = crRed
Else
formula = crBlue
End If

-LB
 
I tried that and it worked. It is highlighting the word 'TRUE' and 'FALSE' in the ConActive row now, but how would I get that entire row to be highlighted with the particular color?
 
Select a cell in the summary grid and then use the first formula to do the conditional coloring.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top