Print Page | Close Window

While loop for printing same record multiple times

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22221
Printed Date: 24 Apr 2024 at 1:49am


Topic: While loop for printing same record multiple times
Posted By: rusmanicai
Subject: While loop for printing same record multiple times
Date 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.



Replies:
Posted By: hilfy
Date 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

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: rusmanicai
Date Posted: 06 Feb 2017 at 7:38am
There isn't a max number of packages.


Posted By: hilfy
Date 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

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window