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

SUM of DBCalc isn't correct..

edited January 2004 in General
Hi,

in the footer of my report, I want the sum of fieldvalue from the
detailband. But the value isn't correct. It is the value of the page
plus the value of the first field on the next page.

How can I fix this general problem?

Best Martin

Comments

  • edited January 2004
    Hi Martin,

    There is a limitation of ReportBuilder when calculating sums inside the
    footer band with a dynamic height detail band. Although we usually do not
    recommend this, you can try summing a TppVariable using the
    DetailBand.AfterPrint event which may help.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2004
    Nico Cizik (Digital Metaphors) schrieb:

    I have done this:

    procedure DeatilAfterPrint;
    begin
    if not blnFirstPass then begin
    intMenge:=intMenge+dbtMengeGesamt.FieldValue;
    dblSumme1:=dblSumme1+dbtSumme1.FieldValue;
    dblSumme2:=dblSumme2+dbtSumme2.FieldValue;
    lblSumme1.Caption:=FormatFloat('#,0.00;-#,0.00', dblSumme1);
    lblSumme2.Caption:=FormatFloat('#,0.00;-#,0.00', dblSumme2);
    lblMenge2.Caption:=IntToStr(intMenge);
    end;
    end;

    But now, I must browse from page to page to get correct SUM on each page.
  • edited January 2004
    Hi Martin,


    are you using grouping functionality?

    Kind regards,

    Mark
  • edited January 2004
    > It is the value of the page plus the value of the first field > on
    the next page.


    ... well - though I had this problem while dealing with several groups
    it was nearly the same: It seems like RB calls the events even when
    "testing" whether a band fits on the end of the page or does not. In my
    case more than one value was calculated double times and though I was
    only calculating a grand total for the whole report I had the same
    effect (browsing page by page resulted in correct values).

    I found a workaround by adding a unique dataset-id
    (AutoIncrement-field) to a collection and checking if an ID was already
    within this collection before adding it to the sum - like:

    IF not IsPrinted(myTableID.Value) THEN
    BEGIN
    Sum:=Sum+myTableTOBEADDED.Value;
    SaveAsAlreadyAdded(myTableID.Value);
    END;


    This way I'm trying to prevent RB from calling this code twice. I know
    that this is complicated - but unfortunately that's the only thing that
    makes me shure that my customers won't get wrong results...

    Kind regards,

    Mark Meyer
  • edited January 2004
    Mark Meyer schrieb:
    No. In this case not.
  • edited January 2004
    Martin

    Mark is correct, most of the events in ReportBuilder are fired numerous
    times during generation. To work around this you will need to compare your
    current record being used to it's previous value when you fired this event
    to be sure you have infact moved on to the next record.

    --
    Best Regards,

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