Report Design
 Crystal Reports Forum : Crystal Reports .NET 2003 : Report Design
Message Icon Topic: While loop for printing same record multiple times Post Reply Post New Topic
Author Message
rusmanicai
Newbie
Newbie
Avatar

Joined: 14 Sep 2011
Location: United States
Online Status: Offline
Posts: 17
Quote rusmanicai Replybullet Topic: While loop for printing same record multiple times
    Posted: 02 Feb 2017 at 9:45am
Hello.

Problem: one shipment with 4 full cartons and 1 odd quantity.
I have a report that pulls the data in the detail section, but brings in 2 records: 1 for the full cartons and 1 for the odd carton.
I need to be able to print first record 4 times and show 1 of 5, 2 of 5 3 of 5 4 of 5 and print the second record once and show 5 of 5.

I tried using the page number as a counter but I get 1 of 2, and 2 of 2 - makes sense since I have just 2 records.

I heard about whileprintingrecords and local variable and tried this formula:

Package x of Y (which is the name of my formula field I would use in my "x of y")

local numbervar i;
whileprintingrecords;
for i :=1 to {@TotalPackages} do i
i:=i+1;


where {@TotalPackages}=#full +1 odd - if exists otherwise =#full

I get an error though - says last row (where I increment) is not part of the formula...

Please help! I cannot figure it out.

Thank you.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 06 Feb 2017 at 7:37am
This one can be a challenge if you can't get the same number of records as you have packages.

Is there a maximum number of packages? If so, how many is it?

-Dell
IP IP Logged
rusmanicai
Newbie
Newbie
Avatar

Joined: 14 Sep 2011
Location: United States
Online Status: Offline
Posts: 17
Quote rusmanicai Replybullet Posted: 06 Feb 2017 at 7:38am
There isn't a max number of packages.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 06 Feb 2017 at 7:53am
Then there really is no way to do this directly in Crystal. You'll need to do something in the database, probably a stored procedure rather than a view, that will give you a number of records that equals the number of packages. Then use the stored procedure to provide the data for the report.

-Dell
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.017 seconds.