[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
Solved

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

Posted on 2016-09-15
Medium Priority
34 Views
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
Question by:Ægir Örn Sveinsson
• 3
• 2

LVL 7

Expert Comment

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 101

Assisted Solution

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

Try this
``````WhilePrintingRecords;
Global NumberVar myRecordNumber;
myRecordNumber := 0;
''
``````

``````WhilePrintingRecords;
Global NumberVar myRecordNumber;
myRecordNumber := myRecordNumber + 1;
If RecordNumber Mod 2 = 0 Then
Color (236,236,236)
else
crNoColor
``````

mlmcc
0

Accepted Solution

Ægir Örn Sveinsson earned 4 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

LVL 101

Assisted Solution

mlmcc earned 1996 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

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 101

Expert Comment

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.

Evaluation Times and the Multi-Pass Model
http://scn.sap.com/docs/DOC-21390

mlmcc
0

Featured Post

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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 …
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll