Monday, July 15, 2013

How to print a subtotal base on per page (Crystal Report)

lets say i have 3 pages in crystal report there should be a subtotal per page

You need to use three formulas ;
Formula 1 : @Reset

Code:
NumberVar x;
WhilePrintingRecords;
x:=0;
 
 Formula 2 : @Sum

Code:
NumberVar x;
WhilePrintingRecords;
x:=x+{DatabaseField};
 
Formula 3 : @Display

Code:
NumberVar x;
WhilePrintingRecords;
x
Place Formula1 in Page Header section and suppress
Place Formula2 in Details section and suppress
Place Formula3 in Page Footer and don't suppress, this is your subtotal
 
Note :
For Duplicates Records :
NumberVar x;
WhilePrintingRecords;
IF OnFirstRecord= true Then
x:= {Databasefield}
Else

if {DatabasefieldKey} <> previous( Databasefieldkey) Then
x:=x+{Databasefield}
ELSe
x:=x ;

No comments:

Post a Comment