Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Help with 'Do While' loop Post Reply Post New Topic
Author Message
myoung
Newbie
Newbie


Joined: 18 Aug 2012
Online Status: Offline
Posts: 1
Quote myoung Replybullet Topic: Help with 'Do While' loop
     Posted: 18 Aug 2012 at 4:02am
I have a spreadsheet as a datasource with about 40 records.... I need to print multiple pages for each record based on the value of one of the cells ('bundles'). If the starting value for the 'bundles' column is 20, I need it to print 20 individual pages....

I have each differentiated record designated as a new group, declare a variable 'bnd' and set it to decrement on each pass:

numbervar bnd = {bundles};
DO
  bnd = bnd - 1
WHILE bnd > 0


When placing the formula in the details or group header, what I get is a note that the value is 'true' for each record, but only one page per record. What logic do I need to use to get it to actually display a decrementing value for the variable 'bnd' and return a page in each instance until the value reaches 0? Where should I place the formula?

Thanks in advance for a kick in the right direction....


IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 20 Aug 2012 at 4:25am
crystal will not generate data, which is what is sounds like you need.
How about another way, Crystal will print each row in the data once, and you want it to print {bundles} time, which is won't do.
 
But...create a spreadsheet as a second datasource and have just a column that is a number from 1 to 100 (will probably work for your report, but you can select any value). Now in table section of Crystal link the 2 tables, the numbers table and the bundle column...if you were doing a select it would be where number <= bundle...
 
Now that I think about it, if you are just doing a straight link/join you would want your table to look like:
1
2
2
3
3
3
4
4
4
4...
 
This will 'multiply' the number of rows that CR sees for the data and allow you to get the report that you are after.
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum