I have a report (using VFP 8.0) with a data grouping by Invoice Number, i need to reset the total of pages by changing of invoice number.
I failed to do so, as the _pagetotal will always return total pages of all selected invoice.
Please advice.
I have a report (using VFP 8.0) with a data grouping by Invoice Number, i need to reset the total of pages by changing of invoice number.
I failed to do so, as the _pagetotal will always return total pages of all selected invoice.
Please advice.
Based on the description, it appears what you want is per my earlier comment... Each invoice has its OWN Page X of Y context where some "groups" have more pages than others. To do what you want typically requires the report to be generated TWICE. Once to run and capture the how many pages at the end of each group. The second instance is the "FINAL". The following is a simple sample on how to do such.
Create your query results, but add an additional column "OfPages" (or whatever you want to represent the per "group" Of Pages count) into a readwrite cursor.
SELECT YourIDGroup, OtherColumns, 000 as OfPages;
FROM YourTable;
ORDER BY 1;
INTO CURSOR C_YourReportCursor readwrite
REPORT FORM TmpPages
REPORT FORM TmpPages preview (or to printer)
Next, in your program, have a function to "catch" the page number at the group footer for whatever your current ID is.
FUNCTION CatchOfPages
LPARAMETERS CurrentID, LastPg
UPDATE DBF( "C_YourReportCursor" );
SET OfPages = LastPg;
WHERE YourIDGroup = CurrentID
*/ Return empty space so nothing is actually printed in the report
RETURN ""
ENDFUNC
Now, the trick. In your report, have your data group based on the ID of the invoice. In the group header, instead of doing page x of y using _pageno and _pagetotal, you will be using _pageno and the column "ofPages" of the cursor... As the first pass will get its proper value updated via the function call above and is set the first time the report is generated but to no output window or printer, just run in the background.
Now, in the group FOOTER, at the bottom, add a textbox control (just as if any other data field output), and set its Expression = the function call with the respectible parameters... ex:
CatchOfPages( YourIDGroup, _PageNo )
It will do the update to the temp cursor (or your result table) with whatever its actual page number is for that final page to the group, and update all records for the associated invoice ID Group, so even page 1 knows its OfPages = 2, 3, 4, or whatever.
To hide / mask the first instance of the report from being seen, hide it in ANOTHER Window, such as
DEFINE WINDOW WinTempReport FROM 0, 0 TO 1, 1
REPORT FORM YourReport IN WINDOW WinTempReport
RELEASE WINDOWS WinTempReport
THEN do your report to normal output.