Total pages per group

I need to be able to get total pages per group.

I've been able to code my script in the group OBP event to reset my own page number variable to 1 when the group changes, but I can't figure out how to keep track of the total number of pages per group.

Page output should look like this

Page 1 of 2
Page 2 of 2
Page 1 of 3
Page 2 of 3
Page 3 of 3

I think part of the issue is that I don't completely understand how variables are affected by two-pass reporting.

Any help greatly appreciated.

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 12:21PM
    Hi a variable is affected each time it is processed, so when you use 2pass report,
    to gather info on the first pass to be used on the second or final pass, code must be written using if finalpass then or if not finalpass then blocks where necessary.
    Take a look at the main report demo see the grouptotals in header demo, it shows how to gather info in an array for each group and then sub the value stored in the array to the variable used to display value on the finalpass.
    regards ;)
  • edited 12:21PM
    Thanks for the information.

    It has helped me get the page numbering output that I desired.

    Regards ;)
  • edited 12:21PM
    ;) gordk
    Can you give me a sample,thx!
  • edited June 2004
    benjoe wrote:
    :rolleyes: gordk
    Can you give me a sample,thx!

    Any variables you see that are not FastReport system variables, I set up in the Data Dictionary.

    You must set up the report as a Two Pass report under the Report Options.

    As suggested, I used an array to keep track of the total pages per group. I put the code to do this in the Group Header/Footer, keeping track of changes in the Order Number in my data set (kbHeader.OrderNo) and adding up the pages per group.

    [Group Header - OnBeforePrint]
    begin
    if [Page#] = 1 then begin
    MyOrderNo := [kbHeader."OrderNo"];
    MyPageNo := 0;
    if FINALPASS then GroupCount := 1 else GroupCount := 0;
    end;

    if MyOrderNo <> [kbHeader."OrderNo"] then begin
    MyPageNo := 0;
    MyOrderNo:= [kbHeader."OrderNo"];
    end;

    MyPageNo := MyPageNo + 1;

    if FINALPASS then TotPageOut := MyTotPages[GroupCount];
    end

    [Group Footer - OnBeforePrint]
    begin
    GroupCount := GroupCount + 1;
    if not(FINALPASS) then MyTotPages[GroupCount] := MyPageNo;
    end

    The output was at the top of my pages, using the following in a Rectangle object
    Page. [MyPageNo] of [TotPageOut]

    Hope this helps

    Kevin Powick
  • edited 12:21PM
    kpowick wrote:
    As suggested, I used an array to keep track of the total pages per group. I put the code to do this in the Group Header/Footer...
    I Don't know why the indenting on the code in my previous reply doesn't show up correctly. Hope you can still read it.

    Regards,

    Kevin Powick

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.