thursdaysgeek
thursdaysgeek

Reputation: 7946

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?

Upvotes: 0

Views: 1613

Answers (3)

Scott Parry
Scott Parry

Reputation: 1

Create a Running total example #shade #shade screenshot

Put this running total in the GroupFooter you want shown on your report (you should have a distinct record to count) now it should have a 1-through however many records are in your GF, then this can be suppressed. Next create a formula called EvenOdd, and use this formula:

If remainder({#shade},2) = 0 then "Even" else "odd"

Drop that formula on your GF and suppress.

Next go to your selection expert, pick your GF, then Color tab, select x-2 and use this formula:

If {@EvenOdd}= "Even" then crWhite else crSilver

This will now show your GF every other line first silver then white. You can choose many color schemes

I have done this as sometimes you may want the details of a report suppressed and only showing a Group. Hope this helps

Upvotes: 0

Arvo
Arvo

Reputation: 10570

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.

Upvotes: 1

Siva
Siva

Reputation: 9101

I think you are resetting the variable so it is not changing.. Don't reset it follow the below process.

In group footer create a formula @counter and write below code

Shared NumberVar counter;

counter:=counter+1 

Now in section expert of the group footer go to color tab and write below code:

shared numbervar counter;

if counter mod 2=0
then crMaroon
else crBlue

Upvotes: 0

Related Questions