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

Initialising of variables - at what point?

edited October 2001 in General
Hi,

I have a fairly strange problem that is happening within a report which I
hope some will be able to solve. In fact, it's something stupid - of that
I'm sure!!

This particular report prints out an item number next to each detail line
that is printed. The item number is incremented in the Gettext event of the
Label - I initialise it to zero in the BeforePrint of the Report component.
I also have a running total that is printed in the footer of each page -
this is calculated manually using a global variable in code after each
detail record is printed.

My problem is that if you preview the report and lets say the first page has
items 1 - 55 and the second page items 56 - 70, if I move to the 2nd page
and then move back to the first page instead of showing Item 1 it now shows
the first number as 71!!! The same happens to the running total - it just
keeps on incrementing as I move back and forth between pages! Obviously, I
was under the impression that page (or report) was already generated so the
calculations would be static thereafter but that clearly is'nt the case. The
same thing happens if the user selects to print multiple copies of the
report - in the above example the 2nd printout would label the first item as
70!

In terms of the running total I should really be using a Report Builder Calc
component but I would have to change the SQL to allow that. However, what do
I do about the Item number problem! Where and when do I reset it to 0 - if a
second copy is printed?

TIA

Campbell Fuller

Comments

  • edited October 2001
    Use a TppVariable and set its type to Integer. Code its OnCalc event
    handler. There shouldn't be any difference between using the TppVariable
    component and the label, except, that the OnCalc will fire only when you
    want it to, because of the settings defined in the variable's popup timing
    dialog. Changing the SQL shouldn't be necessary. You will have a much
    better chance at getting an accurate calculation by using the TppVariable
    instead of the TppLabel.

    The OnGetText will fire every single time the text property is referenced on
    the label.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited October 2001
    Jim,

    Firstly, many thanks for the prompt reply (the normal high standard of
    support from Digital Metaphors!).

    Like most people I jump in feet first and generally regard manuals as an
    EXTRA!. So I actually read some of the manual and immediately found the
    solution to the line numbering problem i.e. a Line no. per detail record!
    (Strange how there are times that a University Degree actually mean squat,
    is'nt it!!!!)

    The second problem, the running total, is still not right but personally I
    believe that I need to rethink the SQL which could be much simpler. So I
    will address that issue first as it will actually be more efficient anyway!

    Thanks for the info.

    Campbell


This discussion has been closed.