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

TppVariables not acting right ???

edited March 2006 in General
?I'm getting what appears to be very odd results from the TppVariables
in my report. I'm using 9.03 in Delphi 2005 Update3. The problem seems
to be 2 fold.

The data set I'm using produces a 3 page report. There's Detail, one
grouping, and a summary band. The summary band contains an average
that's built using a TppVariable. The group band has the same. What
I'm seeing is...

(1) Every time I end a page, the group TppVariable OnCalc gets (set to
veTraversal) fired off for the last record displayed. Then, at the top
of the next page, it fires off for the SAME record.

(2) the Summary band has a TppVariable (also veTraversal) that performs
some averaging. I put a showmessage that dumps out the value every time
the onCalc is called. On the last execution, the value appears right
(adjusting for the duplicates in (1) above). The OnCalc is never called
again, but when the report prints, the number is completely different.
Not zero, but on the order of 270000 where it should be 240000, for
instance. I can't figure out where the number is coming from. It seems
impossible that it's coming from the OnCalc.

I've uploaded the source, database, and executable for a stripped down
version of the report that exposes these issues to my website. You can
find it at http://www.allidare.com/rpttest.zip.

Note, the particular report is a very stripped version of the original.
For instance, in the sample, there ends up being one detail record for
each group. A solution involving the removal of the group band,
however, won't work as the actual report has significantly more data.

Also, the averaging needs to be done in a TppVariable because I'm
averaging numbers that are already incorporated in an average. So
instead of a simple average, I take each detail row and have to multiply
it out before adding it back into the overall average.

The database is a firebird db. I've included the gdb.dll (v1.5) in the
zip file, to make it work "out of the box". Feel free, of course, to
grab a copy from the firebird distribution site if you want to mitigate
the risk that I'm a
hack. :)

Any advice on these oddities would be much appreciated.

Clif



--- posted by geoForum on http://delphi.newswhat.com

Comments

  • edited March 2006
    Hi Clif,

    Some observations about your code.

    1. Are you able to recreate this issue using the DBDEMOS database perhaps?
    This would make it much easier for me to track down the problem as this is
    not a known issue and I am unable to recreate it myself.

    2. You should not have to use the "As" routines of the TppVariable to
    access it's value. If you just use the TppVariable.Value property, the
    conversion to the proper datatype will be automatic.

    3. You should also not have to account for the second pass in the OnCalc
    event if you use the Value parameter to edit its value.. This event was
    designed to only fire once per traversal regardless the pass setting.

    I would first recommend simplifying this to a minimal example and seeing if
    it works as designed for RB.

    procedure TForm2.ppvGrpCntQLCalc(Sender: TObject; var Value: Variant);
    begin
    Value := Value + ppReport1.DataPipeline['TOTALQL'];
    ppVGndCntQL.Value := ppvGndCntQL.Value +
    ppReport1.DataPipeline['TOTALQL'];
    end;

    --
    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.