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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

for loop

Status
Not open for further replies.

adhhealth

Programmer
Jul 1, 2004
165
US
crystal version 8 pervasive sql 6

Hi, my formula looks like the following:

numbervar i:=0;
for i :=1 to {#RTotal1} step 1 do
i;
i;

-THis is to display serial numbers starting from 1 till it reaches the value of the running total.

But the o/p is starting from 2 till {#RTotal1}+1. I dont know what is it that is going wrong.
(i also tried from i:=0 and i:=-1 doesnt work.)
Pl. advise.
 
I would guess that the loop is not being exited until a value greater than the limit is reached. In that case your output needs to be i-1.
But I can't see the point of the formula.
You could use record numbers to number the rows.
 
lupin,
You're assuming that the running total is counting each record. The running total could be in a group header and be incrementing on a condition.


rajaniah,
I'm confused as to why you just don't display the running total field since "i" is incrementing to your running total.


Mike
 

Thank you for the reply!!
I cannot use the record number because i am displaying the rows in a group and each group has many details(i am suppressing the detail) so the first record number will be 1 but the next will be 255.
i displayed the output as i-1. But what i am wondering is why the formula of the loop is not working.everything looks fine to me!!
Thank you!!
 
rajaniadh,
if you insist on using the loop instead of just displaying the running total, change it to this:

numbervar j;
numbervar i;
for i :=1 to {#RTotal1} do
j:=i;

j



Mike
 
mbarron,
by the time i saw your message i had posted mine..
any way , ya i could display the running total instead of the loop. i dont know what i was thinking.
thank you!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top