Page n of m

colingbradleycolingbradley Member Posts: 162
I have a link now:
http://dynamicsuser.net/media/p/8.aspx
From there you can download the original fob and see the construction.

Many thanks for the quick response from David Singleton and via a gentle hint from Mohana.
Thanks guys

original query below...
I need to be able to print the Page number and the total number of pages for each page.
The client does not want to use the preview option.
Is there a way of getting the total pages?

I have some notes from 2006 that did not make a lot of sense to me as they were not explained in sufficient detail for me to get it working.
Can anyone fill in the gaps or suggest a better solution?

What I need help with about the solution below is:

1. Is TestReport a Global Var?
2. Is PageCount a Global Var?
3. The Function ReturnTotalPages has just one line?
CURRREPORT.PAGENO
4. Where do you put the following lines?
e.g. Report - OnPreReport()?


CLEAR(Testreport);
TestReport.SAVEASHTML('c:\test.html');

//Call a function in the report that returns
/"CURRREPORT.PAGENO" after the SAVEASHTML has finished
PageCount := TestReport.ReturnTotalPages;
THE ABOVE LINE GIVES AN ERROR "The type conversion is not possible because one of the operators contains an invalid type" "Integer := VOID"
CLEAR(TestReport);

5. Where do you call a function from?
6. In Function DefTotalPages, what is the Local Parameter called

//Call a funtion in the report and use the PageCount
//as Parameter
TestReport.DefTotalPages(PageCount);
TestReport(RUN);

//END of sample

"TestReport" is a Variable of type Report
"PageCount" is a variable of type Integer
Experience is what you get when you hoped to get money

Comments

  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    There are a lot of "solutions" for this. Most are trying to "pre-print" the report to standard printer in preview mode or as HTML and store the total no. of pages anywhere. But it depends on your printer driver how many pages are used for your report and your current filter. So, there's always a little risk that your total no. isn't correct in the end.

    Try to search the forum for these solutions.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Another way I thought to do this ages ago but never tried.

    Make the assumption that the report will always be printed on the same printer (or at least paper size) and that it runs with the same filters. I think these are fair assumptions for Posted Documents.

    Lets work with Sales Invoice. Add a new field to 112 "No Of Printed Pages"::Integer. Modify Codeunit 315 and add a new function to update the new field with no of pages.

    Now in the Invoice report at the very end, when the last page is printed call the new function to update with CURRPAGENO.

    Now you run the report once with no page numbers but the second time you will have the no of pages. This is probably a simpler solution and as long as you don't change paper size it should be reliable.
    David Singleton
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Also if you are already printing a Copy (say for internal records) then just print that first without page numbers and the second one becomes the original with numbers.
    David Singleton
Sign In or Register to comment.