Search code examples
crystal-reportscrystal-reports-2013

In a group footer, how to get alternating background colour for records in Crystal Reports


This is related to this question, but I want the alternating background color in a group footer. My detail section is suppressed for my subreport, and the grouping gives me a grand total at the end.

So, my suppressed detail has something like this (except I have about a dozen plus types instead of two):

TypeA  100
TypeA   50
TypeB   50
TypeB   30
TypeB   20
Typec  150

And my group footer has the pretty totals

TypeA  150
TypeB  100
TypeC  150

I want the color to turn on and off in the group footer. If I were in the details, I'd use the formula in the color for the section:

IF RecordNumber MOD 2 = 1 THEN
   crNoColor
ELSE
   Color (234,234,234);

But if I do that in the group footer, the RecordNumber might be even several times in a row, then odd, and so I'll get several lines white, then a grey one, then a couple more white.

I've been trying to make a variable that is set to 1 on the first record and increments by one each on each time the group changes. Then I could treat it in the color section like the RecordNumber. So far I've succeeded in making a variable that won't change at all, let alone getting anything to work in the color tab.

What is a good way to make the group footer records have an alternating background color?


Solution

  • There's another system variable - GroupNumber. If you have simple aggregation scheme, not nested groups, then this number can be used exactly like you used RecordNumber.