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

New DBCalc as DBText descendant

edited May 2003 in Component Writing
Hi all,

I'm writing my own tppdbcalc component for calculation like countdistinct. I
derives it from tppdbtext en override the GetTheText and Compute method. But
in my report with this component on a summary band, with a dataset with 24
records, the compute is called more then 24 times. Is ther an event or
method that is called every time e new record is taken from the dataset.

Best regards
Jos Aikema

Comments

  • edited May 2003
    OnGetText will execute every time the Text property of a component is
    referenced. This fires often and more than once per record. Try overriding
    the Compute method and store the computation in the value property.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    Jim,


    I only have override the GetText for some other things. U use the Compute
    method for my counting and i seems to offer more then once per record. What
    am I doing wrong??

    Jos Aikema
  • edited May 2003
    Are you storing the value in Value? Yes, the Compute will get called
    multiple times. If you store the value in DBCalc.Value, then the cache
    manager will restore the value to the previous one automatically so that
    when it fires a second time, it will calculate correctly. If you store the
    value in another field, then it won't work correctly.

    The report engine has to try generating a band to see if it will fit on a
    page. If it fails to fit on a page, it must back up and restore the calc
    component values. Then it regenerates the band again on the next page,
    firing the calcs and other events again for the same record.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.