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

Triggering SummaryBand ppVariable Calc

edited January 2002 in General
I'm having trouble getting ppVariables in Report Footer summary bands to
calculate before being printed.

I have ppVariables in a Report Footer summary band whose values depend on
other ppVariables in the same summary band. For example, I have totals for
wholesale and retail costs, and based on the values of those two totals I
need to calculate Gross Profit (the difference), Margin % (based on a ratio)
etc.

My problem is that the variables are being printed before they're
calculated. (I know this from setting breakpoints in the OnCalc and OnPrint
events.) They therefore come up as zeroes. The only way I've found to assign
them meaningful values is by setting CalcType to veTraversal. This performs
the Report Footer calculations every time a record is traversed, including
the last one, which works for the sake of printing but is overkill. It also
doesn't work for situations where I need some other action to be taken once
and once only in the summary band.

Surely there's a way to set CalcType and CalcComponent to trigger
ppVariables in a summary band to calculate -- once -- before being printed.
No?

--
Stephen Aberle {{8^{ )}
Programmer, Unipharm Wholesale Drugs Ltd.
mailto:stephen_a@unipharm.com

Comments

  • edited January 2002
    Set the CalcOrder of the variables. This only affects the variables in the
    same band. It affects the order of which their OnCalc fires. Only use the
    OnCalc events to perform calculations with variables.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2002
    Thanks. Yes, I tried that. I set the CalcOrder of the derived variables for
    (for example) Gross Profit and Margin to be higher (which, I assume, means
    later) than the source variables. Their values are still left at zero and,
    as I mentioned before, the OnPrint event fires before the OnCalc event for
    these variables when I set them to a CalcType other than veTraversal.

    -Stephen Aberle.

  • edited January 2002
    Oh, whoops, I forgot to also say set the datatype of the TppVariable:)
    There is a drop down list in the left side of the tool bar where you can set
    it. It defaults to String.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2002
    Yup, did that already.
    - Stephen.

  • edited January 2002
    So, is it working or not?


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2002
    No, as I say it only calculates accurate Report Footer values when I set the
    CalcType to veOverkill, whups I mean veTraversal ;-)

    - Stephen Aberle.

  • edited January 2002
    I misunderstood what you were trying to accomplish. When the report engine
    traverses through the dataset, generating detail bands, it triggers the
    OnCalc events of the variables and the dbCalcs in the entire report. If the
    variable is in the summary band, and the timing is set to calculate on
    traversal, then the OnCalc fires every time the record position moves
    forward. Ok, this works well, but if you only want to perform a calculation
    once when the summary band prints, then use the SummaryBand.BeforePrint
    event to perform the calculations.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.