vrijdag 27 september 2013

Crystal Reports: alternating row coloring and hidden rows

A couple of years ago I ran into a problem with Crystal Reports. I had used alternating row coloring based on the formula:

if recordnumber mod 2 = 0 then
    color(255,200,255)
else
    color(255,255,200)

I got:


But now I had to hide some rows bases on a formula, let's say:

{Products.UnitPrice}>50

But now all off a sudden I got irregularities in my alternating row coloring, like this:


After some thinking I created a Running total call Counter:


As Type of Summary I used count. As a formula I used:

{Products.UnitPrice}<=50

The opposite of the suppressing formula.

I then replaced the formula for the alternating row coloring with

if {#counter} mod 2 = 0 then
    color(255,200,255)
else
    color(255,255,200)

And my report was working again!

Een reactie plaatsen