Here is a new Crystal Reports tip from the GP Reports Viewer newsletter collection. I have added an example with some screenshots to better illustrate.
Want to spruce up your Crystal report a little by adding alternate color shading to the lines? Here is how. (Click on the screenshots to see them clearer.)
As an example, let’s start with a report that lists of customers from the GP sample company:
I want to shade the alternating lines to make this a little easier to read. Here are the steps:
-
Go to Report > Section Expert
-
Click on Details on the left and switch to the Color tab on the right
-
Click on the formula button:
- Copy/type the following formula in:
select RecordNumber mod 2
case 0: crWhite
case 1: color(222,222,222)
- Click Save and Close
- Click OK to close the Section Expert window
Here are the results:
You can make the color of the shading anything you want. Crystal has colors that you can call by name, here is the list: crBlack, crMaroon, crGreen, crOlive, crNavy, crPurple, crTeal, crGray, crSilver, crRed, crLime, crYellow, crBlue, crFuchsia, crAqua, crWhite. I have found that most of these are much too dark, so I just pick my own RGB colors.
If you want to shade Group lines instead of Detail lines, change the formula to the following:
select GroupNumber mod 2
case 0: crWhite
case 1: color(222,222,222)
Thank you! I could not remember “RecordNumber” … I kept using RecordCount, Count etc etc. It was driving me crazy.
LikeLike
YESSSS ! Without you I have no job !!!!
LikeLike
Thanks for the tips Victoria! It’s so simple and easy to understand! Works like a charm for me 😉
LikeLike
Great! So simple yet so effective unlike other complicated tutorials for a simple question.
LikeLike
Thanks very helpful
LikeLike
thanks…great work
LikeLike
WOW!! Thanks… so easy. One question… if I want to pick a lighter shade as you were suggesting using your own RGB choices, how do I do that?
LikeLike
Mana,
You’d have to figure out the RGB numbers for the color you want. An easy way of doing this would be to go into any application that has a color option. For example, in Crystal 2008, select any field on the Design tab, click on the Font Color icon, choose More and play with the colors on the right side – once you find the color you like, note the Red, Green and Blue (RGB) numbers for it on the bottom right and fill those in instead of the 222,222,222 in my example. Hope that helps.
-Victoria
LikeLike
Thanks for the tip Victoria 🙂 Great one!
LikeLike
can u limit the width of the colored lines?
LikeLike
Dru,
I am not aware of any way to limit the width of the lines.
-Victoria
LikeLike
select RecordNumber mod 2
whats “RecordNumber mod 2”? thanks
LikeLike
Dru,
The ‘mod’ function in Crystal divides one number by another and returns the remainder. So any odd number divided by 2 will have a remainder of 1 and any even number divided by 2 will have a remainder of 0.
-Victoria
LikeLike