Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Want robust solution for alternating row color, resetting every group

I would like a solution for displaying an alternating row color for my detail rows that resets every group, so that row 1 is always gray.

Our Crystal designer provided this code to me:

@rowcnt formula, suppressed, placed in Detail row:

Shared numbervar rowcnt;

rowcnt := rowcnt + 1;

@resetrowcnt, suppressed, placed in Group row:

Shared numbervar rowcnt;

rowcnt := 0;

Formatting formula, placed in Color in Detail > Section Expert:

Shared numbervar rowcnt;

if Remainder(rowcnt, 2) <> 0 then

color(241,241,241)

else

crWhite

This was working fine for me.

However, it is suddenly not working in one of my reports.

The report does happen to have two groups (rowcount.png).

When the report is run, all rows are colored (rowcount02.png).

This report was previously working fine!  I'm not sure what changed.

In any case... surely there must be standard code to do this very standard formatting.

I would be very grateful if someone could post some robust code to accomplish the following:

REPORT DATA IN DETAIL ROW, ALTERNATE ROW BANDING:

- Data in Detail row displays alternating row colors

- Odd rows are always shaded, even rows not

- Banding resets every group / does not continue pattern from previous group

REPORT DATA IN GROUP ROW, ALTERNATE ROW BANDING:

Some of our reports place row data in a group row (just the way it happened).

If you could also modify your code in this case.

Thank you!

rowcount02.png (98854 B)
rowcount.png (19497 B)
Former Member
Former Member replied

Hi Vancouver,

-- Do you have any conditional suppress for detail section through Section Expert ? If so, you need to use the same condition for your accumulation formula.

-- Are you using 'rowcnt' variable name anywhere else in your report ? i.e. in any other formulas ?

Try to replace your formula with below formulas :

Reset formula :

Whileprintingrecords;

Numbervar cnt:=0;

row count Formula:

Whileprintingrecords;

Numbervar cnt:=cnt+1;

Detail section expert formula :

Whileprintingrecords;

Numbervar cnt;

if cnt mod 2 <> 0 Then Crred else crwhite

Thanks,

Sastry

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question