Search code examples
countcrystal-reportssummary

Record count in footer per page


I have a report that has a detail section limited to 6 records per page and I have two jobs to do for these records. One is to split to two pages as soon as specified value is in specified DataField and another to display sum of the records per page.

I tried with my current knowledge and I am getting only total sum and not per page record sum.

I will try to explain with sample:
Let's say I have a report with 12 records for details section and the total equals to 12 (1 per each record). But my report prints 6 records per page so I need to print 6 as a sum of per page records. And if by chance one of them splits because of predefined logic and lets say I have 3 page of this report with 2, 6 and 4 records per page then I need to print 2, 6 and 4 as totals. In best case scenario I get 12 on each page and in other cases error.

I found this post Get sum of a field per page in crystal report

It looks exactly what I want but was not able to find where to declare variable. I know it says "Create a variable in the report header" but where is that report header? Or could you advice where to read actual manual on Crystal Report?


Solution

  • From your scenario it is clear that you want to print records count per page in Page Footer Section. You can achieve it as follows. Create three formula fields in report design and set their values in formula editor as under:

    1. ff_Reset_Total

      whileprintingrecords;
      numbervar runningtot;
      runningtot:=0;
      
    2. ff_Current_Total

      whileprintingrecords;
      numbervar runningtot;
      runningtot;
      
    3. ff_Add_Record

      whileprintingrecords;
      numbervar runningtot;
      runningtot:=runningtot + 1;
      

    Now place these formula fields in your report as under:

    1. ff_Reset_Total in Page Header Section
    2. ff_Current_Total in Page Footer Section
    3. ff_Add_Record in your Details Section

    Then using formatting options Suppress the ff_Reset_Total and ff_Add_Record