Solved

Alternating colors - Want the first color of the detail band within a group to be always the same

Posted on 2016-09-15
7
15 Views
Last Modified: 2016-10-05
I have a formula like this:

If RecordNumber Mod 2 = 0 Then Color (236,236,236) else crNoColor

What I get with this is that it is random whether the first color within the group is grey or white.

How can I change it so that the first line is always grey?
0
Comment
Question by:Ægir Örn Sveinsson
  • 3
  • 2
7 Comments
 
LVL 6

Expert Comment

by:DPatel
ID: 41799646
sometimes you end up with groups inexplicably not shown in alternating colors. This probably has something to do with conditional suppression of group records. Instead of depending on the GroupNumber NumberVar, we will just do something similar to a manual running total:

Shared NumberVar GroupNum;
GroupNum := GroupNum + 1;
if Remainder(GroupNum, 2) = 0 then crNoColor
else Color(236,236,236)
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 499 total points (awarded by participants)
ID: 41799736
It has nothing to do with groups being suppressed.

Try this
Add a formula to the report header and the group header
WhilePrintingRecords;
Global NumberVar myRecordNumber;
myRecordNumber := 0;
''

Open in new window


Change your color formula to
WhilePrintingRecords;
Global NumberVar myRecordNumber;
myRecordNumber := myRecordNumber + 1;
If RecordNumber Mod 2 = 0 Then 
      Color (236,236,236) 
else 
      crNoColor

Open in new window


mlmcc
0
 

Accepted Solution

by:
Ægir Örn Sveinsson earned 1 total points (awarded by participants)
ID: 41801211
Neither of those solution seemed to be working correctly. I did however find a way to get this to work by doing this:

1. Put this formula in the group header:

Shared NumberVar myGroupRecordNumber;
myGroupRecordNumber := 0;

2. Put this formula in the detailband:

Shared NumberVar myGroupRecordNumber;
myGroupRecordNumber := myGroupRecordNumber + 1;

If myGroupRecordNumber Mod 2 = 1 Then Color (236,236,236) else crNoColor

This creates exactly the effect I want :)
Thanks :)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 499 total points (awarded by participants)
ID: 41801468
MIne has a minor typo in the If.  It uses RecordNumber rather than MyRecordNumber

Change that and try it.

mlmcc
1
 

Author Comment

by:Ægir Örn Sveinsson
ID: 41801631
Thanks. I am a beginner in this so I would like to ask: What is the purpose with the statement "WhilePrintingRecords;"?

This seems to be working, even though it is not there.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 41802024
WhilePrintingRecords tells the report engine when to evaluate the formula.

The Printing Records pass is the last pass through the report.

Shared variables are intended to be used for sharing information between a main report and a subreport.  By definition they are evaluated in the Printing records pass so the directive is not needed.  I usually add it to document when the formula will be evaluated.

Since my formulas use GLOBAL variables rather than SHARED the directive is needed.  If it not included then the engine determines when to do the evaluation which may be the wrong time in the report evaluation process.

For more information see this article from Crystal,  It is a bit dated but the process used is still the same.
Evaluation Times and the Multi-Pass Model
http://scn.sap.com/docs/DOC-21390

mlmcc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal Report Error 14 72
Store total calculated duration sessions. 44 75
Crystal Reports last day of month 2 44
Pagination Difference  in crystal report 7 42
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…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

20 Experts available now in Live!

Get 1:1 Help Now