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

OnCalc does not works properly

edited May 2003 in General
I have a report which has a sub-report. The sub-report's detail band has a
TppVariable, this variable is computed based on 2 fields in each record.
I have a particular problem here, when I preview the report and click the
last page button directly from first page, this variable is not computed
correctly only for the first row of the last page (eg. result should be 6
but I see 3), and sometimes it is blank. This only happen to the first row
in a page where the details overflow from previous page. On the other hand,
if I click the next page button to view the report page by page, and scroll
to the last page, this variable (first row) is computed correctly. It is
also correct if I send the report to printer.

From my experience in using Report Builder, I realised that the TppVariable
sometimes is not functioning correctly if I preview the report and select
the required page number or click the last page without scrolling through
each page.

What is the possible cause of this problem? My report is using TwoPass. RB
version is 7.01 with Delphi version 7.

Thanks in advance.

Comments

  • edited May 2003
    Are you storing the value in anything other than the Variable.Value? If you
    are, then that is the problem. The value is not getting restored from cache
    across page breaks. The OnCalc fires again for a detail band when it must
    attmept to print on the next page when it can't fit on the previous page.
    The OnCalc has to fire again, but the calculation should works because RB
    restores its value as if it never fired for the previous page when the
    detail couldn't fit.

    If the problem persists, please send a simple example to
    support@digital-metpahors.com.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    I did not store the value in anything. These are my code:-

    procedure TForm1.ppVariable5Calc(Sender: TObject; var Value: Variant);
    begin
    inherited;
    { Convert Quantity to Combine UOM }
    Value := FormatBaseToCombineUom(qrySummary.FieldByName
    ('BASE_QTY').AsFloat, qrySummary.FieldByName('CVT_FACTOR').AsFloat)
    end;

  • edited May 2003
    Can you send a simple example project to support@digital-metaphors.com that
    shows the problem an we can take a look at it.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    It is difficult to create a simple project for that particular report.
    Anyway I will try to generate a simple project togather with the similar
    problem in below.

    I have another report which will keep on generating when I click the last
    page during preview, it suppose to have 25pages, but the report footer shows
    calculating page 26 and hang until I click the cancel button. I would not
    have this problem if I change the report to OnePass. I guess the TwoPass
    setting + random page preview combination will create problem. Any hint for
    myself to do further investigation?

    TQ

  • edited May 2003
    Try disconnecting your event handlers one by one in order to isolate the
    code causing the problem. Then try to recreate this using a DBDEMOS based
    report and send it to support@digital-metaphors.com


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.