Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counter doesn't work

Status
Not open for further replies.

faisalsham

Programmer
Mar 11, 2005
18
0
0
US
hello all,

this is what I want my result set to look like:

ID counter
-------------
100 1
100 1
123 2
123 2
135 3
136 4

I want the counter to increment anytime I have a new ID. I have the following code in a formula in the details section:
Code:
dim intcounter as number
if  PreviousValue ({rptInvoiceList.Workflow_Id}) <> {rptInvoiceList.Workflow_Id} then
    intcounter = intcounter+1
end if
formula = intcounter

but that returned all 1's ... it didn't increment like I thought it would.

Am I doing something wrong here??

thanks in advance...
 
Posting basic technical information will prove fruitful, at least your aoftware version...

Place a Running Total in there and use a distinct count on the field.

Here's your formula in Crystal syntax which should also work:

whileprintingrecords;
numbervar intcounter;
if recordnumber <> 1 and
Previous({rptInvoiceList.Workflow_Id}) <> {rptInvoiceList.Workflow_Id} then
intcounter := intcounter + 1;
intcounter

I say *should* because this depends on your report layout, groups, etc.

-k
 
thanks for the quick reply synapsevampire...

however, the code you posted is pretty much the same as the one I posted (mine is in vb syntax) and this is what I'm getting:

ID counter
-------------
100 1
100 1
123 1
123 1
135 1
136 1

by the way, I'm using CR 9.0
can you please expand on how you would like me to keep a running total?

thanks.
 
Insert a Running Total (built in to Crystal), and select distinct count, there's no code required.

Where are you placing the formula??? Do you have groups???

Your post doesn't really convey WHERE you are doing anything, try to be specific.

If it's in the detail section it will work, and our formulas are different, I allow for the first row.

-k
 
Thanks for the quick reply again Synapsevampire,

If you read my first post, I do mention that the formula is in the detail section.

Yes, I know that your formula allows for the first row but that is the only difference between the two formulas... and it still doesn't work.

No groups.. just a basic report.
Again, what field would you like me to insert a running total on?

How will that impact the end result I'm looking for (specified in my first post)?

thanks again.
 
I converted the VB syntax to the Crystal syntax and it worked!

it's weird why it doesn't work for the VB syntax.

thanks again for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top