Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  


Alternate Row Colors in Crystal Report
Often you see something like this:

Format Section - Color Tab, click on the formula for specifying the background color, and enter:
if RecordNumber mod 2 = 1 then Color (233, 233, 233) else crNoColor

But that only changes the color on every other RECORD. What if you're grouping or suppressing records???
If you want to change the background color on every other GROUP, or on every other FUNCTION, then you have to do something a little more complicated

Add a formula called 'Alternate' to your report. The formula should be (VB syntax):
shared alternate_record as boolean
alternate_record = not alternate_record
formula = alternate_record

Then, set the background color formula (as above) to:
if {@Alternate} then Color (233, 233, 233) else crNoColor

Created By: amos 4/14/2006 6:25:17 PM
Updated: 1/30/2017 8:46:22 AM

 > Guest 1/29/2009 4:38:59 PM
All you need to do is use the groupnumber for rownumber and it will work fine in sub reports or reports where results are grouped in a single line for each group. A formula is not required to accomplish this...
 > Guest 2/10/2009 12:15:30 PM
As the author stated, your solution will not be sufficient if you are suppressing records. But nice try.
 > Guest 2/10/2009 12:19:37 PM
my bad, the solution above doesn't work with suppressed records, either!
 > Guest 7/21/2009 7:38:36 PM
That works well! thanks.
 > Guest 12/16/2009 10:32:46 AM
fantastic - many thanks
 > Guest 3/4/2011 11:03:59 AM
Top notch. This drove me bonkers. Thanks!
 > Guest 3/4/2011 11:04:43 AM
 > Guest 4/21/2011 11:04:50 AM
it give me an error between shared and alternate_record
a variable type (for example, 'numberVar') is missing
 > Guest 9/20/2011 4:14:22 PM
Is there a formula to alternate colors based on date.

I have a report which is seperated into groups and then sorted by date. I may have several incidents on a particular date and I would like thase in one color while the next group of dates are another.
 > Guest 9/29/2011 8:06:08 AM
 > Guest 6/12/2012 5:29:40 PM
This solution doesn't work :( Is there another one?