chrislindsay
asked on
Crystal Report for next loop syntax issue
Hi Experts,
I have a report which I would like to use a variable, up to a required maximum which is a field value in my database.
I want to use the value (i) to multiple incrementally in a group footer.
I'm not sure how to define the local variable and where to put it once I have defined it
The correct syntax would be greatly received!
Thanks
I have a report which I would like to use a variable, up to a required maximum which is a field value in my database.
I want to use the value (i) to multiple incrementally in a group footer.
I'm not sure how to define the local variable and where to put it once I have defined it
The correct syntax would be greatly received!
Thanks
for i = 1 to (max_capacity)
next x
ASKER
Hi Thanks for the reply but I really want a limit of i = 1 to max where max is a value in a table.
When I complete the group calculation, I would like to increase i + 1 until I reach the max value and the report would loop again until max was reached
Thanks
When I complete the group calculation, I would like to increase i + 1 until I reach the max value and the report would loop again until max was reached
Thanks
The report goes through records one at a time. There is no way to loop again?
What are you trying to do with this?
Are you trying to get a record to display several times?
mlmcc
What are you trying to do with this?
Are you trying to get a record to display several times?
mlmcc
ASKER
The report looks at a formule and uses the value 1 (i) in the calculation (multiple places) (loop i+1)
the report looks at the same formule but uses the value 2 at (loopi +1)
until maxvalue.
I will return approx 200 lines (from my data) of different results as I will use i as a group below the group I am summarising)
Is this any clearer? Thanks
Chris
the report looks at the same formule but uses the value 2 at (loopi +1)
until maxvalue.
I will return approx 200 lines (from my data) of different results as I will use i as a group below the group I am summarising)
Is this any clearer? Thanks
Chris
Not really.
Can you show a sample data and where the values would be used?
mlmcc
Can you show a sample data and where the values would be used?
mlmcc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Already thought of creating a dummy table in Sql but was really looking for a more elegant approach. Thanks for your asisstance guys
FWIW, you don't necessarily have to create a new table for this. Basically, you just need a table with at least as many rows as you'll need iterations for your calculations. But there are a couple of caveats.
1) Ideally, the table would include record numbers, so you could use the record selection to control how many records the subreport reads (record_number_field <= max_capacity).
2) Without a record number field, you'll have to use suppression, which means that CR will read every record and just not show the "extras", so you'd look for some table (or group of records within a table) that had as many records as you'd ever need, but not much more, to try to minimize the reading of unnecessary records. For example, if max_capacity will never exceed 100, a 10,000 record table is probably not a great solution. :-)
James
1) Ideally, the table would include record numbers, so you could use the record selection to control how many records the subreport reads (record_number_field <= max_capacity).
2) Without a record number field, you'll have to use suppression, which means that CR will read every record and just not show the "extras", so you'd look for some table (or group of records within a table) that had as many records as you'd ever need, but not much more, to try to minimize the reading of unnecessary records. For example, if max_capacity will never exceed 100, a 10,000 record table is probably not a great solution. :-)
James
ASKER
Thanks James thats useful infomation.
No problem.
I should explain that my point in # 1 was that if you have a record number field that you can check in the record selection, that test will hopefully be passed to the server, so the server only sends the required number of records. I just realized that I hadn't explained why you'd want to have a record number field and check it in the record selection.
James
I should explain that my point in # 1 was that if you have a record number field that you can check in the record selection, that test will hopefully be passed to the server, so the server only sends the required number of records. I just realized that I hadn't explained why you'd want to have a record number field and check it in the record selection.
James
ASKER
Thanks James.
I have overcome this issue and have a nice loop, and have another which I have just published.
Thanks again
I have overcome this issue and have a nice loop, and have another which I have just published.
Thanks again
No problem, again. :-) Glad you were able to work it out.
James
James
I think what you want is this
In the report header add a formula
WhilePrintingRecords;
Global NumberVar i;
i := 1;
''
In the groupfooter
WhilePrintingRecords;
Global NumberVar i;
i := i + 1;
mlmcc