Link to home
Start Free TrialLog in
Avatar of Clif
ClifFlag for United States of America

asked on

Alternating Row Colours with a Twist

I have a report that allows viewing detail or summary.  
The report lines are as follows:
Report Header
Page Header
Group Header #1a
Group Header #1b
Details
Group Footer #1
Page Footer
Report Footer

For Detail
Detail line is not suppressed
Group Header #1b is suppressed

For Summary
Detail line is suppressed
Group Header #1b is not suppressed

I know how to alternate line colours in the detail, and that works fine.  However I also need to alternate line colours for the summary which is not working as planned.  I tried putting the same code in the Group Header #1b background colour code behind, but the colours don't alternate.  There is groups of two or three that are one colour and then a group of the alternate colour, etc.

How do I alternate colours on Group Headers (when Detail line is suppressed)
Avatar of Mike McCracken
Mike McCracken

Try this

I don't know what you are using for the formulas but if you include the test for suppression and evaluate only when the section is NOT suppressed it might work.

If you need help, please post the formulas you are using to alternate the colors.

mlmcc
Avatar of Clif

ASKER

Was there supposed to be something after the "Try this"?

I have tried various methods for alternating colours, including trying setting a flag on when off and off when on.  Nothing seems to work.
One try:
If
    Remainder (RecordNumber,2)<>0
then
    crSilver
else
    crwhite

Open in new window


Another try (gLastPrintRow is a global variable):
numberVar gLastPrintRow;
If 
    gLastPrintRow = 0 
then
    (    
    gLastPrintRow := 1;
    crSilver
    )
else
    (
    gLastPrintRow := 0;
    crwhite
    );

Open in new window

Yes except my idea wasn't going to be too helpful without seeing your formulas

Does group header 1A need to alternate colors?

For the group headers, recordnumber won't work because you aren't alternating every other unless the group only has 1 record.

Unless you need GH1A to alternate try using this on GH1B

WhilePrintingRecords;
Global numberVar gLastPrintRow;
gLastPrintRow := gLastPrintRow + 1;
If     Remainder (gLastPrintRow ,2) = 0 then
    crSilver
else
    crwhite


Also add a formula to the report header
WhilePrintingRecords;
Global numberVar gLastPrintRow;
""

mlmcc
Avatar of Clif

ASKER

Sorry, that didn't do it.

It was, actually, very similar to another try at it I had made.
ASKER CERTIFIED SOLUTION
Avatar of Kurt Reinhardt
Kurt Reinhardt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Clif

ASKER

rhinok
Sorry, but none of your group alternating rows worked.  I keep getting something like the following:

NoColour
NoColour
NoColour
Silver
Silver
NoColour
Silver
Silver
Silver
Silver
NoColour
Silver
NoColour

It's different combinations depending on which code snippet of yours I use.

You are right in that I am usingt a parameter field to select whether the user sees detail or summary
Those are pretty standard formulas and I even wrote a proof of concept report in Crystal Reports XI R2 against the Xtreme Sample database 11.5.  They all work perfectly.  So, there has to be something in your specific conditional formatting that's conflicting. Are you trying to have both group header and detail records colored at the same time?  In my example, it's one or the other, depending on the parameter value.

If you have access to that database, please see the attachment.

~Kurt
AlternatingColors-CRXIR2.rpt
Avatar of Clif

ASKER

Header and detail are not printing at the same time, so I don't care if they are coloured the same at the same time.

I finally tried the one you gave to have the colouring always start on the first item (using a running total) and that seems to have worked.

Thanks.