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
13 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 5

Expert Comment

by:D Patel
Comment Utility
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)
Comment Utility
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)
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 499 total points (awarded by participants)
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

11 Experts available now in Live!

Get 1:1 Help Now