Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Page Totals in Summary Band

edited November 2005 in General
Hi,

I posted a while ago asking about a problem I was having calculating
page totals. This is now working correctly. Now, I'd like to print the
page totals in the summary band.

The method I'm using works correctly if the user just prints the report,
or if they click through the report from the first page to the last page
(in the preview). If the user clicks the go to last page, or clicks on
only some of the pages, the summary only displays the information for
those pages that were clicked on.

I have tried the report using different combinations of PassSetting and
CachePages, but no combination seemed to make a difference. I've search
through the contents of this newsgroup, but nothing I found seemed
related to my problem.

I've placed two variables and a dbmemo on my report. Variable1 is in the
Footer band, and is responsible for calculating the page total.
Variable2 is in the Summary band and is responsible for accumulating the
lines for the Summary. The dbmemo is used to display the resulting summary.

The code attached to the controls is as follows:

procedure TForm1.ppVariable1Calc(Sender: TObject; var Value: Variant);
begin
// add the total for this line to the page total
ppVariable1.Value := ppVariable1.Value +
ppReport1.DataPipeline.GetFieldValue('TotNum_1');
end;

procedure TForm1.ppVariable1GetText(Sender: TObject; var Text: String);
begin
// add the total for this page to the summary
ppVariable2.Value := ppVariable2.Value + #13#10 +
IntToStr(ppReport1.AbsolutePageNo) + ': ' + Text;

// display the page total
Text := ppVariable1.Value;
end;

procedure TForm1.ppDBMemo2GetMemo(Sender: TObject; aLines: TStrings);
begin
// display the accumulated summary text
ALines.Text := ppVariable2.Value;
end;

I've emailed what I hope is a minimal example to
support@digital-metaphors.com.

Regards
Gareth Marshall

Comments

  • edited November 2005
    Gareth Marshall wrote:


    What kind of summary should the displayed?


    OK, I'll try...

    1.
    Variable' (summarys) of every page should be resetted at OnStartPage.
    Footer
    (assume that it's just the summary of the current page)
    Page 1 = 100,- (var reset at pagestart)
    page 2 = 100,- (var reset at pagestart)

    For the total in summary band just use a dbcalc(sum)
    Total = 200,-

    2.
    if you would like to display on every page the running total use
    dbcal(sum)...

    3.
    display on every page the page total (see 1.) and the "overall total"
    use a two pass report, store at the end of the first pass the "overall
    total" and assign that to a var "myOverallTotal" that is placed in the
    footers..





    add's and add's....

    in RAP take care of
    "if detail.OutOfSpace then... (don't add!)"


    just use a running total..



    Footer ? summary? running total? ...
    If it's a summary just use a TppDBCalc...


    HIH
    ralf
  • edited November 2005
    Hi Gareth,

    Try setting the Report.CachePages property to True and see if that helps the
    issue. I'm out of the office today but I'll have a look at your example
    when I get back on Monday.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    Hi Ralf


    The idea is to put a total for each page at the bottom of that page. On
    the final page, a list of the pages is displayed, along with the total
    for each of those pages.


    The variable is reset on vePageEnd - this is to ensure that the total is
    correct when the report wraps. In the example I emailed to dm, the
    totals are as follows:

    Page 1: 140
    Page 2: 87



    This is not suitable, because it displays the total of all the pages,
    rather than the total for each page as a separate item.



    I want to display the page total, rather than the running total.


    The grand total doesn't need to be displayed on each page.


    I'm not really sure what you mean by that. It works just fine to
    calculate the page total.


    I really don't want to have to use RAP. I automatically produce the
    report using code every time the user wants to generate a report. It is
    all done using Delphi code at the moment - I'd prefer to avoid having
    parts of the implemenation in Delphi and parts in RAP.


    This is for Variable1 which diplays the total for the page. It also adds
    the total for the page to the variable that gets displayed on the report
    summary.


    This is in the summary band. It basically just displays the page totals
    that were displayed in the summary band. Remember that the value of
    Variable2 is determined like this by the variable displaying the page
    totals (in ppVariable1GetText):




    It is a summary. I can't use a TppDBCalc (at least as far as I know)
    because the summary needs to display the total for each page.


    Let me give you an example of the kind of report I'd like to produce.

    --- Page 1 ---

    10
    20
    30
    40
    50

    Page Total: 150

    --- Page 2 ---

    60
    70
    80



    Page Total: 210

    --- Page 3 ---

    Page 1: 150
    Page 2: 210

    --- End of Report ---

    Thank you for your help
    Gareth Marshall
  • edited November 2005
    Hi Nico


    The example I emailed you does have CachePages turned on.


    Thank you very much for your help

    Kind regards
    Gareth Marshall
  • edited November 2005
    Hi Nico

  • edited November 2005
    This thread has been handled through email.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.