Solved

Alternating Row Colours with a Twist

Posted on 2011-03-18
8
1,526 Views
Last Modified: 2012-05-11
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)
0
Comment
Question by:Clif
  • 4
  • 2
  • 2
8 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
0
 
LVL 10

Author Comment

by:Clif
Comment Utility
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

0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
0
 
LVL 10

Author Comment

by:Clif
Comment Utility
Sorry, that didn't do it.

It was, actually, very similar to another try at it I had made.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 26

Accepted Solution

by:
Kurt Reinhardt earned 500 total points
Comment Utility
Generally, speaking, the base formulas for alternating detail row colors is:

If
  Remainder(RecordNumber,2) = 0
Then
  crSilver//or some other color
Else
  crNoColor//you don't need to specify white

Open in new window


The following formula for alternating group colors is:

If
  Remainder(GroupNumber,2) = 0
Then
  crSilver//or some other color
Else
  crNoColor//you don't need to specify white

Open in new window


If you want to customize the shading further, such as ensuring that detail records in each group always start with the same shade, you would use a running total to reset the record count within each group and then use it in your detail color formula:

If
  Remainder({#GroupRecordCount,2) = 0
Then
  crSilver//or some other color
Else
  crNoColor//you don't need to specify white

Open in new window


In your case, how are you determining whether or not detail records are shown? Is this based on a parameter such as {?ShowDetail} with values of Y or N?  If so, you would use the following type of conditional formulas:

Detail section:

If
  {?ShowDetail} = 'Y' and
  Remainder(GroupNumber,2) = 0
Then
  crSilver//or some other color
Else
  crNoColor//you don't need to specify white

Open in new window


Group Header:

If
  {?ShowDetail} = 'N' and
  Remainder(GroupNumber,2) = 0
Then
  crSilver//or some other color
Else
  crNoColor//you don't need to specify white

Open in new window


~Kurt
0
 
LVL 10

Author Comment

by:Clif
Comment Utility
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
0
 
LVL 26

Expert Comment

by:Kurt Reinhardt
Comment Utility
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
0
 
LVL 10

Author Comment

by:Clif
Comment Utility
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.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now