?
Solved

Alternating Row Colours with a Twist

Posted on 2011-03-18
8
Medium Priority
?
1,844 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 35167652
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
ID: 35167855
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 101

Expert Comment

by:mlmcc
ID: 35167942
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 10

Author Comment

by:Clif
ID: 35168605
Sorry, that didn't do it.

It was, actually, very similar to another try at it I had made.
0
 
LVL 26

Accepted Solution

by:
Kurt Reinhardt earned 2000 total points
ID: 35168614
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
ID: 35168925
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
ID: 35169202
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
ID: 35180734
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

770 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