Link to home
Start Free TrialLog in
Avatar of Ægir Örn Sveinsson
Ægir Örn Sveinsson

asked on

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

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?
Avatar of D Patel
D Patel
Flag of India image

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)
SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ægir Örn Sveinsson
Ægir Örn Sveinsson

ASKER

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