Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

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
7
Medium Priority
?
31 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
[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
  • 3
  • 2
7 Comments
 
LVL 7

Expert Comment

by:D Patel
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

by:mlmcc
mlmcc earned 1996 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 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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
LVL 101

Assisted Solution

by:mlmcc
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

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 101

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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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. …
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 …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

618 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