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
24 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 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 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

827 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