Duplex and Total Page Count issue

Posted on 2007-08-07
Last Modified: 2012-06-27
Crystal 10 - Oracle db.

I'm having trouble correcting the 'total page count' of a report. This is necessary because I am conditionally adding an extra page to assist with duplex printing.

The report will be used to generate customer statements. I am grouping by the statement code, the customer account number and the statement month number. If a statement ends on an odd page I am conditionally showing a group footer section of the month number - which is large enough to create the extra page needed for duplex printing.

The problem is I don't want to count this extra page in the page count  total. How do I conditionally subtract 1 from the total page count of each statement whenever I show the extra page?


Question by:fkimonis
    LVL 42

    Expert Comment

    Create this formula and use it to show the total number of pages - it'll subtract one from the total if it's an odd number:

    if totalpagecount mod 2 = 1 then
      totalpagecount - 1

    Author Comment

    Hi frodoman,

    That doesn't work because totalpagecount will always be even - having added the extra page to compensate for duplex printing.

    BTW the  total page count is shown in the page header of report.

    Any other suggestions would be greatly appreciated.

    LVL 42

    Expert Comment


    Unfortunately I don't think you're going to be able to do this.  The problem is that your conditional suppression must take place during the WhilePrintingRecords phase which is also when any formula you create that uses TotalPageCount must also be evaluated.  The page header is going to be rendered before the group footer is so you're stuck.  I tried using a shared variable in the conditional suppression formula and tried forcing the page number formula in the page header to evaluate later but Crystal won't do it.

    The only way I can think of to accomplish this is if you can find another way to handle the conditional suppression - something based on record count or the like that could be evaluated during the whilereadingrecords phase so there is time in the whileprintingrecords phase to do something with the information.

    LVL 100

    Expert Comment

    I agree.  SInce you add the page, it gets counted.

    You might be able to set a flag in the section but I suspect it will be set too late to be useful.

    LVL 28

    Accepted Solution

    I believe I was able to accomplish what you.
    I will describe a report I just built using the Xtreme sample db, and then you can replicate it in your report.

    Create a new report using the Orders table.
    Group on Customer ID, place Order ID and Order Amount in the details section.
    I resized the details section so I could get a group to span more than 1 page.
    Open the Section Expert, click on Group Footer 1 and click Insert.
    You should now have a Group Footer 1a and 1b sections.
    Click on the parent Group Footer 1 section and set the property "Reset Page Number After"
    Click on Group Footer 1a and click the X+2 button to the right of New Page After, then paste this logic there:

    remainder(pagenumber,2) = 1

    Save and CLose.
    Click on Group Footer 1b and click the X+2 button to the right of New Page After and paste this logic there:

    not onlastrecord

    Save and Close.
    then close the Section Expert.
    Place the Page N Of M field in the Page Header section
    The last thing to do is to suppress the Page N Of M field.
    You will need to create 2 new formulas:

    //@Set Suppress Flag to False - Place this formula in Group Header 1 and Suppress it
    global booleanvar suppress_flag := false;

    //@Set Suppress Flag to True - Place this formula into Group Footer 1a and Suppress it
    global booleanvar suppress_flag;
    if remainder(pagenumber,2) = 1
    then suppress_flag := true;

    Now, right click the Page N of M field, choose Format field.
    Click the X+2 button to the right of Suppress, and paste this line there:

    global booleanvar suppress_flag = true

    Save and Close and Test it out.
    LVL 42

    Expert Comment

    Nice!  Very creative solution bdreed.


    Author Comment


    I followed the instructions and then moved the logic onto my statement report. The solution provided by bdreed35  has sorted out the page numbering issue, and added an extra page whenever the group ends on an odd number. :)

    There is a slight problem with my summing up at group level. The total transaction amount needs to be displayed at the bottom of the last page where there are transactions.  - "print at bottom of page" on the group footer seems to add an extra page even if the statement ends on an even number.

    Guys - I'm new to this - Do I accept the solution and open another follow up issue?



    Author Comment


    Managed to solve the totals issue!

    I moved the total to the page footer and conditionally show it using both the suppress_flag and a new suppress_footer_flag. This new variable switches to 'false' in Group Header 1 and to 'true' in Group Footer 1b.

    Thanks again to frodoman and bdreed35 for taking the time to help me with this issue. :)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now