Microsoft Dynamics GP Developing for Dynamics GP
A blog dedicated to the Microsoft Dynamics GP Developer & Consultant community
 
Welcome to MSDN Blogs Sign in | Join | Help

Developing for Dynamics GP

by David Musgrave (Australia) and the Microsoft Dynamics GP Developer Support Team (USA)

News

  • Please use the Blog Feedback? - Contact Us link at the top of the page to email questions relating to the blog itself.

    If you wish to ask a technical question, please use the links below to ask on the Newsgroups. If you ask on the Newsgroups, others in the community can respond and the answers are available for everyone in the future.

    Please do not use comments on pages and posts to ask questions unrelated to the topic on that page or post.



    Dates of Interest:

    11-Jul-2008: Blog Created by David Musgrave.
    10-Oct-2008: First Post by Scott Stephenson.
    04-Nov-2008: First Post by Dave Dusek.
    11-Nov-2008: First Post by Beth Gardner.
    28-Nov-2008: First Post by Chris Roehrich.
    30-Dec-2008: First Post by Patrick Roth.
    24-Feb-2009: First Post by Greg Willson.
    22-Apr-2009: First Post by David Clauson.
    04-May-2009: First Post by Ryan Wigestrand.
    19-Jun-2009: First Post by Dawn Langlie.
    03-Jul-2009: First Post by Emily Halvorson.
    23-Sep-2009: Created Twitter account with blog feed.



    WorldMaps Statistics since
    24-Feb-2009:




    Click for WorldMaps Stumbler



    Translator Tool:




    Social Networking

    Follow David Musgrave and the blog on:

    David Musgrave on Twitter

    David Musgrave on LinkedIn


    Disclaimer

    This blog is provided "AS IS" with no warranties, and confers no rights.

    The links in this blog may lead to third-party Web sites. Microsoft provides third-party resources to help you find customer service and/or technical support resources. Information at these sites may change without notice. Microsoft is not responsible for the content at any third-party Web sites and does not guarantee the accuracy of third-party information.

Contents

Favourite Posts

Blog Links

Newsgroups Links

Resources Links

RW - Can I print Page Numbers including the Total Number of Pages?

David MeegoThe question in more detail is whether it is possible to print "Page: Y/X" or "Page: Y of X" on a Report Writer report, where Y is the current page number and X is the total number of pages for the report.

This question was asked again on the Partner Forum recently. It is one that has been asked on numerous occasions in the past and so I thought I would explain why the answer is "No .... well .... maybe".

The Dynamics Report Writer is a single pass report writer.  This means it runs through the data once and prints section of each page as it is completed until it reaches the end. As it cannot tell in advance how much data is being printed and what additional headers and footers will be printed, it will not know the total number of pages until it finishes printing the last page.

So if we are talking about only using the Report Writer, then including the total number of pages is not possible.

OK, why did I say "maybe"?

If you really want this feature and are registered for Visual Basic for Applications (VBA), I believe it would be possible to estimate the number of pages. This is just a concept and to date I have not actually written the code.  You will need to decide if the amount of work required is worth the benefit of having the total number of pages.

You could use the Report_Start() event to read the legend values to get the range of records the report will be printing,  then you can create a connection to SQL Server via ADO (ActiveX Data Objects) and identify the amount of data.  For example: Identify a SOP transaction, read the number of lines and comments for those lines and lot and serial numbers for those lines.

Once you know how much data there is and how many lines can be printed on each page, you can calculate the estimated total number of pages.  Using the Report_BeforePH() event you can increment the number of the current page and then set a blank string calculated field to the value of "Page Y of X".

There are some other aspects that should be looked at to help derive the formula for the number of lines that will be printed.  You need to take into account the restrictions on the report definition window as well as whether the body or additional headers and footers sections are suppressed for any conditions.  Finally, you can use the method in the post below to identify any additional restrictions added by the Dexterity calling code:

Finding out how to call an existing Report

One final point to mention is that this technique will be more complex when the report is based off a temporary table.  When a temporary table is used, you would need to go back to the source data tables and reproduce some of the logic for creating the temporary table to identify the number of records that would be included in the temporary table.  While not impossible, extra work is required.

Please see the following post for more information on working with Report Writer, VBA and ADO:

Using VBA with Report Writer

Using ADO with VBA with Report Writer 

Please add a comment if you have written something similar to this concept.

David 

Posted: Wednesday, May 13, 2009 9:00 AM by David Musgrave
Filed under: , ,

Comments

rdrag said:

David, I've been promoting SQL Server Reporting Services to our clients for several years now.  I've always said that SSRS is a better tools than Crystal or GP Report Writer, except if you're creating a customer-facing document such as a purchase order or invoice.  I just recently created my first SOP Invoice report in SSRS that supports batch printing (one report = multiple invoices), and learned that I was definutely correct.

I'm sure some RW users would shout "Why doesn't this tool support page numbers by transaction!"  Well,  SSRS has the same problem.  Overall, the invoice is pretty great, but page numbering was a real challenge.

I eventually found a post (http://blogs.msdn.com/chrishays/archive/2006/01/05/ResetPageNumberOnGroup.aspx) from a SSRS team member on how to at least show the page number by group, but I seem to be completely unable to show "Page X of Y".  

So, if anyone out there feels tempted to begin cursing RW, know that SSRS is not perfect either.

Ron Draganowski

Solution Services Practice Manager

Olsen Thielen Technologies, Inc.

St Paul, Minnesota

rdrag@ottechnologies.com

http://www.ottechnologies.com

Find me on LinkedIn: http://www.linkedin.com/in/rondraganowski

# May 13, 2009 11:41 AM

Ariel said:

David,

I have a question. How could I calculate the lines number for a report when the user can change the paper size or the orientation.

I've tried in GP 10 the Report_GetPageSize but it loses GP with an error and if I try Report_GetPageRemaining I have an error too.

Thanks, Ariel Laniado

ariells@credivico.com.ar

# September 8, 2009 3:07 PM

Patrick Roth [MSFT] said:

Ariel,

The Report function library is only used for if you are creating a report on the fly such as what GP uses to print financials (balance sheet, etc).  That is why you don't modify those report in report writer.

You mention when you call this you "lose GP with an error" meaning a Watson error.  My guess is because in order to use this function you need to use Report_Begin().  But you cannot do this as a report is already printing.

Yes I do understand that the user can change page size and orientation to mess up your page count.  However the approach to calculating the number of pages is completely depending on section size, page size etc, and if the end user is changing these things they'd really have to change the calucation.

# September 8, 2009 4:37 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker