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

dbcalc problem

edited October 2003 in General
I have a report with header, detail, summary and footer. In then
footer i have a DBCalc of a fields of the detail band.

When i print the report, the dbcalc value is wrong because include the first
line of the next page.

I think that this problem appear becaouse in the header band i have two
subreport without datapipeline, an after, a region;
the two subreports in some cases aren't visible.

Please note that the header bands have a dynamic height.

If i move the dbcalc in the detail band (each detail row print a progressive
total), the total i rigth !

Thanks in advance for your support !

Massimo

Comments

  • edited October 2003
    Hi Massimo,

    Instead of using DBCalcs, try using TppVariables instead. Place a variable
    in the detail band and in its OnCalc event update the value of another
    variable in the footer after pulling the data directly out of the
    datapipeline. The following article gives a good example of this...


    ------------------------------------------------------
    Tech Tip: Calculating a Summary based on Group Totals
    ------------------------------------------------------

    Question: I am using a Variable in the Group Footer to conditionally
    calculate totals for each group. I want to add a second Variable to the
    Summary that accumulates the results calculated for each group.

    The following example uses two Variable components: vCustomerTotal and
    vCustomerSummary. The variable vCustomerTotal has its Timing defined to
    Reset on GroupEnd.


    There are two options for accumulating the summary total.

    1. Use the vCustomerTotal OnCalc event to accumulate the detail and the
    summary.

    example:

    procedure vCustomerTotalOnCalc(Sender: TObject; var Value: Variant);
    begin

    if (plCustomer['Amountpaid'] > 100.00) then
    begin
    {sum detail}
    Value := Value + plCustomer['Amountpaid'];

    {accumulate summary}
    vCustomerSummary.Value := vCustomerSummary.Value +
    plCustomer['Amountpaid'];
    end;

    end;


    2. Set the timing of the Summary OnCalc to "GroupBeforeFooter" and
    accumulate the detail variable results. Note that here we use
    GroupBeforeFooter because the detail variable has its Reset defined as
    "GroupEnd" - implying that if we try to use GroupEnd for our summary
    calculation the accumulated results will be 0.

    example:

    procedure vCustomerTotalOnCalc(Sender: TObject; var Value: Variant);
    begin

    {sum detail}
    if plCustomer['Amountpaid'] > 100.00 then
    Value := Value + plCustomer['Amountpaid'];

    end;


    procedure vCustomerSummaryOnCalc(Sender: TObject; var Value: Variant);
    begin

    {accumulate summary}
    Value := Value + vCustomerTotal.Value;

    end;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2003
    Thanks Nico for your answer.

    You mean that the dbcalc component have a bug ?
    I can't immagine that with this component isn't possible to sum a database
    field and have this total in the footer band, without sum the first value of
    the next page.

    Please note that i don't have any group in my report but simple i want to
    sum a fileld for each page and print the total in the footer band.

    Thanks in advance.



  • edited October 2003
    Hi Massimo,

    The DBCalc does not have a bug that we know of. In some cases, it is better
    to use variables rather than a DBCalc depending on the design of the report.
    If possible, please send a small example demonstrating the issue you are
    having in .zip format to support@digital-metaphors.com and I'll take a look
    at it for you.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2003
    This is a multi-part message in MIME format.
  • edited November 2003
    Hi Graeme,

    I am having a little trouble understanding the layout of your report. Do
    you have a subreport inside a region in your detail band that traverses
    through the expenses? If possible please try to create a small example
    using the DBDEMOS database and has a similar layout to your report and send
    it to support@digital-metaphors.com in .zip format. Also a screenshot of
    your current report's design layout would be helpful.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2003
    Hi Nico


    No, we have 2 or 3 data pipelines with the required data. One for the
    Header details (Addresses, names, etc..), one with the details and
    sometimes one with footer info ( Bank account details, tax details etc..).

    We then use Groups inside the report. We also have a region control in
    our detail line, with all the relevant controls inside that region. The
    transaction description is a DBRichText control. The user can enter
    transaction descriptions with different fonts, underline things etc.. in
    our program. So the transaction description can be one line or many
    lines. The balance b/f line is placed inside the GroupHeader band. The
    totals are placed inside the Footer band. Even if our invoice only has
    one line, the totals must always print on the same place at the bottom
    of the page. We also use the Page Style band to draw all the lines and
    boxes in our report.

    I will try and create a sample app that loads data from a saved
    TClientDataset or try and put together a sample report that duplicates
    the the problem with the DBDemos data. I will also attach one of our
    clients Invoice .rtm file.

    Regards,
    - Graeme -
This discussion has been closed.