Solved

Alternating Row Colours with a Twist

Posted on 2011-03-18
8
1,654 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
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 100

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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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 500 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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. …
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

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