I’m sure there are many of us who remember the green bar continuous form paper that spewed out of the old dot matrix printers. The horizontal green bar assisted the reader with following a line of text across the page. Often a horizontal line is used in Crystal Reports for the same purpose. But there are times that I find that these lines just add more black ink to the page – and that instead of making it easier to read, actually make it harder. Instead, I’m going to use a background color to highlight alternate rows, and create a differentiation between my records.
Setting the Conditional Formatting
In order to apply the conditional formatting that will create alternating colors for our rows, we will need to create a formula associated with the background color of the selected section. Begin by opening the Section Expert for your Details Section, and then select the Color tab. Check “Background color” and select one of your desired colors. Now click the Formula button next to the color selector.
We will be creating a formula that applies the Modulus operator to the Running Total field Count
. The modulus operator returns the remainder when one number is divided by another. When Count ÷ 2
has no remainder, then Count
is an even number. Using this operator, we can easily switch between applying one background color or the other. The entire formula is as follows:
//Background Color formula
IF {#Count} mod 2 = 0
THEN Color(227,227,227)
ELSE crWhite
You can choose any two colors; I am using white and an RGB value for pale grey. If you have multiple Details Sections, you will need to repeat this process and create a formula for each of your Details Sections.
With the formula added to each Details Section, your Crystal Report will now highlight alternate rows, making the information easier to read.
Thanks for taking the time to read my post – I hope you found it helpful.
Leave feedback in the comments below.
If this post save you time, then consider sharing it with your friends and colleagues. If it saved you some money, then please consider buying me a coffee. If you want to know when I publish new content, then subscribe to my feed. Your support encourages me to write more. Thanks!