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

Using variable

edited July 2007 in General
Hi.

I've a problem with the TppVariable component that seem to work well
with RB 9.02 on Delphi 7 but it doesn't with DB 10.06 with Delphi 2007.

I built a simple test with the DBDemos database and the employee table.
I put a TDatabase, TTable, TDataSource, TppDBPipeline, TppReport and I
joined all toghether. Then I opened the RB designer I put 2 TppDBText
with two field and a TppVariable in the detail band. Then I wrote this
code in the onCalc event handler of the TppVariable:

procedure TForm1.ppVariable1Calc(Sender: TObject; var Value: Variant);
begin
if VarToStr(Value) = '' then
Value := 0;
Value := StrToInt(Value) + 1;
end;

The problem is that the first value I see on the variable is 2 instead
of 1. It seems that the event is fired two times for the first record.

Thanks in advance.
Luca Minuti.

Comments

  • edited July 2007
    Hi Luca,

    If possible, please send this example to support@digital-metaphors.com in
    .zip format and I'll take a look at it for you.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2007
    Nico Cizik (Digital Metaphors):


    Done.

    Thanks,
    Luca Minuti.
  • edited July 2007
    I look forward to reading more about this as I reported exactly this issue
    only this week.

    My work around, Luca, was to put the code that adds to the variable inside
    the DBText's OnPrint event that only appears to fire once.

    Jason.

  • edited July 2007
    Currently String type variables are only to be used to display string
    values, not perform calculations. If you need to perform a calculation, be
    sure to use a numerical type.

    From our email correspondence....

    ---

    Upon further research, I found that we had purposefully changed the way
    String variables interact. This was due to the fact that String Variables
    were not properly being cached across page breaks. What exactly are you
    trying to accomplish? Would it be possible to change the type of the
    variable in your report to a numerical type (integer, double, etc)?

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