Print Page | Close Window

Crstal Report alternate color Help?

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6240
Printed Date: 28 Apr 2024 at 10:42pm


Topic: Crstal Report alternate color Help?
Posted By: imran_amodi1
Subject: Crstal Report alternate color Help?
Date Posted: 02 May 2009 at 7:23am

Hello Friends,
I have a crystal report, Crystal Report contains a Table and I change the alternate color of the Rows using the following formula:

if RecordNumber mod 2 = 0 then crSilver else crNoColor
I want the alternate color to be within the Table, but the alternate color is applied outside the Table also. How to do it?
Thanks.




Replies:
Posted By: DBlank
Date Posted: 02 May 2009 at 9:43am
1. What do you mean by a "table"? A crosstab or something else?
2. Where exactly did you place the formula?


Posted By: imran_amodi1
Date Posted: 02 May 2009 at 11:30pm

Hello DBlank,

                         Sorry for not being clear.

1.       What do you mean by a “table”? A crosstab or something else?

a.       I added a Group section (Right-Click on Details Section ->Report -> Group Expert).

b.      I used line objects to draw a table around the group section( Right-Click on Report -> Insert -> line )

2.       Where exactly did you place the formula?

a.       Right-Click on Details Section -> Report -> Section Expert  -> Select Details in the Sections list -> Select color TAB -> Check BackGround Color ->  click small Button beside colors ComboBox for formula workshop . ( wrote that above formula )

Thanks.

 



Posted By: DBlank
Date Posted: 04 May 2009 at 6:48am

Still not sure exactly how this is functioning othe than perhaps your "table" is only in one grouping and not another.

If this is the case you can add another condition into the formula to only highlight every other row under that conditin also.
something like:
if RecordNumber mod 2 = 0 and {table.field}=condition then crSilver else crNoColor
if that does not work can you explan your set up more and conditionally where you need it to color and not color?


Posted By: lockwelle
Date Posted: 05 May 2009 at 6:05am
It sounds like you applied the alternating color scheme to the details section, but you drew your table around a group section...
 
If you only want the group section to alternate, you would need to put the color formula on the group section. 
 
If I have this right, your formula might give inconsistent results as the record numbers might all be even or odd, depending on the detail records below them.  If so, you might want to change to a shared variable to use as a counter.
 
 


Posted By: skailey
Date Posted: 13 Jul 2009 at 1:24pm

Hey everyone.. I am new here and stumbled across this thread and I hope you can help me.  I have a similar situation, however, I have records that may have multiple rows, or may not.  I need the details section to alternate based on the record, not the row.  For example:

 
record A
record A
record A
record B
record C
record C
record D
record D
record D
 
I have played around with it and don't seem to be able to get it quite right.  Any help would be appreciated.
 
Thanks!


Posted By: DBlank
Date Posted: 13 Jul 2009 at 1:41pm
Create a Running Total as:
Name="ColorCounter" (or whatever you want)
Field to summarize= RECORD A, B , C field (from above)
Type of Summary is = COUNT
Evaluate as= On change of field (same field as above)
RESET = Never.
 
You can place this on your detail row to validate it and it should look like this:
 
record A  1
record A  1
record A  1
record B   2
record C  3
record C  3
record D   4
record D   4
record D   4
 
Now you can use the conditional formula to change your color as:
if {#ColorCounter} mod 2 = 0 then crBlue else crBlack
 
To change the ink color for the field REcord A,B,C... right click on it, select Format Field.
Click on the Font Tab
Click on the Color Formula and add in:
if {#ColorCounter} mod 2 = 0 then crBlue else crBlack
 
To Bold it add the formula in the Style option (just above the color option) as:
if {#ColorCounter} mod 2 = 0 then crBold else crRegular


Posted By: skailey
Date Posted: 13 Jul 2009 at 1:54pm
Works like a charm.  Thank you!


Posted By: skailey
Date Posted: 28 Sep 2009 at 11:23am
Hello, I am back and I am now needing to modify how this is working for my report.  I am now supressing loans in the detail section of the report where I was not doing so before.  It worked great when I wasn't supressing anything from the detail section, but now that I am, the color coding below is still working on all records, instead of those that are just showing up in the detail section (that do not meet the supression criteria).  Any ideas on how I can apply this to those loans that don't meet the supression criteria?
 
Thanks for your help!


Posted By: DBlank
Date Posted: 28 Sep 2009 at 11:41am
Change your RT evaluation to use a formula. The formula will be 2 parts.
The first part is your condition to show the row (opposite of your suppress condition) and the second is on change of the field as next(record ABCfield)<>recordABCfield


Posted By: skailey
Date Posted: 28 Sep 2009 at 12:13pm
Thanks DBlank.  It still does not seem to be working properly.  Here is what I have, maybe a second pair of eyes can see what I am missing.
 
My suppression formula for records in the detail section is:
 
({view.DaysCount1}) < (({view.DaysCount1Standard}) + 30)
AND ({view.DaysCount2}) < (({view.DaysCount2Standard}) + 30)
AND (({view.DaysCount3}) < (({view.DaysCount3Standard}) + 30) OR {view.marker3} = "")
AND ({view.DaysCount4}) < (({view.DaysCount4Standard}) + 30)
 
So, per your suggestion... the first part of the formula to show the row is:
 
({view.DaysCount1}) >= (({view.DaysCount1Standard}) + 30)
AND ({view.DaysCount2}) >= (({view.DaysCount2Standard}) + 30)
AND (({view.DaysCount3}) >= (({view.DaysCount3Standard}) + 30) AND {view.marker3} <> "")
AND ({view.DaysCount4}) >= (({view.DaysCount4Standard}) + 30)
 
and the change of field is:
 
Next (view.ABCfield) <> ABCfield
 
My bgcolor on the detail section is still coded as mentioned above in your post from July. 
 
On the report, it looks pretty random.
 
Record A
Record A
Record A
Record B
Record B
Record C
 


Posted By: Pink
Date Posted: 28 Sep 2009 at 12:20pm
I'm not sure to understand exactly your problem, but here is how I do it :

WhilePrintingRecords;
if RecordNumber mod 2 = 0 then
crSilver
else
crWhite

Never had bad feed back from client about it....

Pink


Posted By: skailey
Date Posted: 28 Sep 2009 at 12:22pm
Yeah, that is how I have been doing it Pink.  It is something with the counter that is the issue, not the piece that you mentioned.


Posted By: DBlank
Date Posted: 28 Sep 2009 at 12:30pm
Sorry. Trying to think this through...
You just have to adjust your RT formula to include / exclude the records that you want so your counter works correctly.
Try:
NOT(
({view.DaysCount1}) < (({view.DaysCount1Standard}) + 30)
AND ({view.DaysCount2}) < (({view.DaysCount2Standard}) + 30)
AND (({view.DaysCount3}) < (({view.DaysCount3Standard}) + 30) OR {view.marker3} = "")
AND ({view.DaysCount4}) < (({view.DaysCount4Standard}) + 30)
)
AND
Previous(abcfield)<>abcfield


Posted By: skailey
Date Posted: 28 Sep 2009 at 12:39pm
DBlank,
 
That worked, as well as the previous version.  I was putting the second part of the formula in the "Reset" formula section of the Running Total Counter instead of putting it in with the records I wanted to look at.  Once I changed that back to "Never" and added the Previous(ABCField) <> ABCField to the RT formula, it worked great.
 
Thanks for all of your help.  These forums are a life saver.


Posted By: Pink
Date Posted: 28 Sep 2009 at 1:19pm
I dont understand why you need a counter....

I had the same result(looked like random) as you mentionned when I first tried to do alternate row color. I found that default is "WhileReadingRecords" thats why I added "WhilePrintingRecords;" and all my problems where solved since supressed row are not printed...

Anyway, as someone "important" said one day : "All roads lead to Rome"...lolll




Posted By: DBlank
Date Posted: 28 Sep 2009 at 1:26pm

The original need had to do with highlighting like rows so it was not a straight alternate row highlighting.

record A
record A
record A
record B
record C
record C
record D
record D
record D

 



Posted By: skailey
Date Posted: 28 Sep 2009 at 1:29pm
That is correct.  Record A would have 3 detail lines (2 suppressed) and I wanted each record to be an alternate color.



Print Page | Close Window