Home RAP

Getting a sequential count in Rap

edited February 2010 in RAP
Hello,

I am trying to print a simple sequential count on detail rows in a
subreport. I tried the following:
I created a global variable: rowcount.
I created a variable on my report on the detail line: vrSequence.

in the onCalc event for vrSequence, I use the following:
RowCount := RowCount + 1;
Value := RowCount;

There is a significant twist to the final report. My final (printed)
report consists of a number of individually designed reports (the above
code is one of them) and these individual reports become subreports in a
single, large report which is built in code.

In other words, I merge the individual reports as subreports into a
larger complex report.

So it seems the global variable becomes global to the new generated
report and by the time the first row in my desired subreport is printed,
the RowCount is not 1 but some higher number.

I also notice that if I move back and forth in the screen preview, the
RowCount increments each time I redisplay the page.

I know I could generate a sequence number in the data side (SQL), but I
would really like to find a way to do this all within the report designer.

I am using ReportBuilder Enterprise Edition, Version 11.07.

Thanks,
Phil Horst

Comments

  • edited February 2010

    Here is an rbWiki 'How To' that I think will help you.

    http://www.digital-metaphors.com/rbWiki/RAP/Calculations/How_To...Access_Subreport_Values_in_the_Main_Report

    (Never use global variables perform calculations. )


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2010
    Nard Moseley (Digital Metaphors) wrote:
    Hello Nard,

    Thanks for your reply. However, I don't think this addresses my
    situation. I probably didn't describe the situation very well. Let me
    try to explain further.

    At design time, I design the report, place this sequence variable on the
    detail line, in RAP, define a global variable and increment it in the
    oncalc event. This works fine at design time.

    However, at run-time, this simple report becomes the subreport of a
    larger, more complex report. I am not trying to access this subreport in
    the main report. Simply, I want the rowcount to start at 1 and increment
    by 1 each new detail row.

    What I am finding, when I generate and run the report, the rowcount does
    not start at one, but some larger number. And it is consistent if one
    pages back and forth in screen preview mode. It seems that the fact that
    this report becomes a subreport in the run-time generated report makes
    it act this way.

    Does this make it more clear?

    Thanks,
    Phil
  • edited February 2010
    I did some more exploring and I find that changing the report from two
    to one-pass makes a difference. The rowcount value starts at 3 on the
    first detail row this appears and when set to two-pass it starts at 6.

    It still increments if I page forward and then backward in screen
    preview mode.

    Might it be connected to the resetting of the variable in the Timing
    setting?

    Thanks again,
    Phil
  • edited February 2010

    To get a simple count you can use the DBCalc component and set to the
    CalcType to ctCount

    or

    Use a Variable and increment the Value like this

    Variable.Value := Variable.Value + 1;

    You cannot use a global variable, such as you are doing with RowCount. That
    will provide the incorrect behavior you are experiencing. A TppVariable
    knows how to save/restore its value as of the start/end of each page.



    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.