Home RAP

how to sum variables

edited September 2002 in RAP
Hello,

I want to print in a master-detail-report at the end of every page (in the
footerband) the sum of all PRINTED (not absolutely the traversed) itemprices
and on the top of the next page the same value.

How can i achieve this with variables in RAP?

The report (invoice) is setting to psTwoPass. The users shell to see in the
page-preview the same "correct" sums, no matter whether they navigate
forward or backward.

Thanks
Juergen

Comments

  • edited September 2002
    There is a technique which uses variables in the detail subreport and in
    conjunction with variables in the main report to print totals in the summary
    band. You can use the same approach to print to variables in the footer
    band of the main report instead of the summary band. However, the current
    example works only with non KeepTogether components on the detail subreport.
    We'll have to build an example which works with KeepTogether for a future
    tip.

    http://www.digital-metaphors.com/tips/SubreportTotalsInMainSummary.zip

    That works fine in Delphi code, however, to do it in RAP requires an extra
    step. You have to create a global variable in RAP that holds a handle to the
    TppVariable in the main report, so that the OnCalc event handler in the
    subreport can access the main TppVariable via the global handle to it. Here
    is an example template:

    http://www.digital-metaphors.com/tips/MDRapRunningTotal.zip


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    Hello Jim,
    thank you very much.

    I did it like in the example, but the sums in the PageFooter are sometimes
    wrong. Only sometimes. My Detailband has no components with KeepTogether,
    but the height is dynamic because of one stretching DBMemo. If one Detail
    does not fit on to the page, the variable in the detailband calculates the
    new sum too early and the value in the PageFooter is to high. Have you any
    idea, what i can do?

    Cheers,
    Juergen
  • edited September 2002
    Here is a modified example to handle KeepTogether:

    http://www.digital-metaphors.com/tips/SubreportTotalsInMainSummary.zip


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    Hello Jim,

    i tested your new example SubreportTotalsInMainSummary.zip.
    But this won't work for me.

    My SubReport detail band prints at first one item and the price (in one
    line) and below it a stretching DBMemo (additional text to the item).
    KeepTogether is set to false, PrintHeight is set to phDynamic, no groups in
    the mainreport and the subreport.

    My goal is to print (and to preview) in the page footer the sum of all
    PRINTED itemprices and on the next page in to the page header the same
    value.

    How can i do this with variables? Cashing the variables is perhaps the right
    technique.
    But in my case, i have no idea, because the "OnCalc" Event fires before the
    detail band of the subreport is generated or the itemprice is printed.

    Cheers
    Juergen
This discussion has been closed.