Tuesday 1 March 2011

Crystal Reports Page Totals

note: old post moved from another old blog


Using Crystal 10 for reference.
Doing a lot with crystal reports this last week or so and I find it eh... challenging as I wish to do some which I consider basis stuff like totals on every page. Crystal does not support this very well so I after a few google searches I put together something that works quite well to my surprise.
First is to create 3 formulas for your running totals. Forget the supported running totals supported in the design. Create each formula and then drag and drop it onto your crystal design

Formula 1: Balance_Reset : Placed on page header-section
WhilePrintingRecords;
NumberVar BalanceDue_total;
BalanceDue_total := 0



Formula 2: Balance_Cum : Placed on Detail section
WhilePrintingRecords;
NumberVar BalanceDue_total;
BalanceDue_total := BalanceDue_total + {@BalanceDue};



Formula 3: Balance_Display : Placed on Page Footer
WhilePrintingRecords;
NumberVar BalanceDue_total;



How this works.
The “WhilePrintingRecords” occurs after all the back end data has been compiled and can be used to do stuff before the page is rendered into a visual entity. See crystal help for a better explanation.

The Balance_Reset formuala in the page header sets the BalanceDue_Total to zero.

The Balance_Cum  adds cumulative values of @BalanceDue (which is a formula derived from database fields) to BalanceDue_total.

The Balance_Display displays the total value on the page footer.
  
TopTip: Only the display formula has to be on non-suppressed section. I created a suppressed sections for Page Header and for Detail to keep the design nice and clean and this works fine.

No comments:

Post a Comment

Comments are welcome, but are moderated and may take a wee while before shown.