Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: coloring grouped records Post Reply Post New Topic
Author Message
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Topic: coloring grouped records
     Posted: 16 Dec 2010 at 8:22am
I have a number of records broken into different groups based on the "category name" and have created a group based on that field.

For readability, I want to have alternating colors for each group.

So something like

1
1
1
1


2
2


3
3
3
3
3
3
3
3


What kind of formula would this go under?

Edited by Keikoku - 16 Dec 2010 at 8:23am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 16 Dec 2010 at 8:42am
can't quite tell if you are in a detials section or header and if you want the background or a field changed but basically...
 
create a Running Total (e.g. #BGcolor) to get your value of 1,2,3
base this on doing either a distinctcount of the grouped on value or
a count that is only evaluated once per group
then if you want the BG color use the section expert (in the section you are changing) go the the color tab and use a formula to change the color as you desire
 

If ({#BGcolor} Mod 2 = 1) Then CRred Else crBlack;



Edited by DBlank - 16 Dec 2010 at 8:43am
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 16 Dec 2010 at 9:54am
Yes, it is the details section.
I am not sure if the numbers made it confusing, but would the same process work for (a more precise example)

Category 1
   cat1 record
   cat1 record
   cat1 record

Category 2
   cat2 record
   cat2 record

Category 3
   cat3 record
   cat3 record
   cat3 record
   cat3 record
   cat3 record
   cat3 record


Edited by Keikoku - 16 Dec 2010 at 9:54am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 16 Dec 2010 at 10:06am
Yes
create a RT
Name=InkColor
Field to summarize=table.category
Type of summary=DistinctCount
Evaluate=for each record
reset = never.
place this on both the group header and the details section
you should see the numers increment once per group change
you can then suppress these fields
 
in the group header right click and select format field
select font tab
select the format field next to the color tab
insert your formual here
If ({#InkColor} Mod 2 = 1) Then CRred Else crGreen;
Repeat this process on the cat1 record field in the detail section


Edited by DBlank - 16 Dec 2010 at 10:07am
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum