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.
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
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
It has helped me get the page numbering output that I desired.
Regards
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
Regards,
Kevin Powick