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

Loop Structure 1

Status
Not open for further replies.

dzdncnfsd

MIS
Jul 14, 2000
118
0
0
US
I have a report that allows the user to specify an item that they want to print a barcode label for. Now I need to add the capability for them to print multiple copies of the same label. I can set up a parameter field for them to choose the number of copies they want, but I don't know how to set up the loop that will actually print them out. Please help??!!

Thank You.
Gladys

Gladys Clemmer

 
Please clarify how you are distributing the report. Is the user running the report from within Crystal? A vb app? A Web browser? And is the label that they want multiple copies of the only one on the report?
 
FVTrainer,
They are running it from within a VB app. I am using Avery Label 5161, so there are 20 labels per page. (2 x 10) I have a parameter field that allows them to specify one item that they need multiple labels for. They may need 1, or they may need 50.
Thanks,
Gladys

Gladys Clemmer

 
Well, Crystal (unlike MS Word) doesn't have a built-in repeat label feature. Instead it presents each record in the report's dataset as an individual label. And since the number of labels you want is very dynamic you really only have one choice that I can see, and that is to return a dataset to Crystal that contains as many records as there are labels to print.

You have a couple of ways you could use to accomplish this task. First, if your database supports stored procedures, I would suggest writing a stored procedure that: 1) Takes a parameter from the user indicating how many copies to print; 2) Gets the one record containing all the info for the label; 3) Inserts that record x times (based on the parameter value) into a temp table; and 4) return the contents of the temp table as a recordset (select * from temptable). Using such a stored proc as your datasource would address your issue.

If a stored proc is not an answer for you, you could use the Crystal Data Object as the report's datasource. If you haven't used the CDO before, it is essentially an array in VB that is passed to a Crystal report at runtime, with the array containing the data for the report. You initially build the report either using an ADO connection or a ttx file as the source (in other words, the Active Data driver), and then at runtime you pass the CDO to the report. If you want to see a very simple sample of how the CDO works click on the following link and download the CDO Tutorial.


In your case, you'd populate the CDO array in VB with as many rows worth of lable info as indicated by the user. Then, you'd pass the CDO to the report. Instant labels.

Let me know if you find either of those approaches useful.
 
FVTrainer,
Wow, lots of info!! I don't have access to the VB code for this particular application, so I think the stored procedure method will work for me.
Thank you so much for your help.
Gladys

Gladys Clemmer

 
Another way is to do this is to create sort of a Template for all possible labels that you want to generate.

So there are 20 to a page....

You might want a couple of parameters

{?StartLabel} - to start printing on a certain label
(useful if they start on a half empty sheet)
Limit the start position to a max of 20)
(?LabelsWanted} - Indicate taht the max labels possible are
60 (ie. three sheets). If they start with
a partially filled sheet then
{?StartLabel} + {?LabelsWanted} must be
<= 60

now you create a detail section with 30 sections...each section is designed to accept 2 identical labels&quot;

I assume that you are passing the complete label into this report...otherwise you will require a formula to create the text...all of the headers/footers...including pageheaders/footers and reportheaders/footers must be suppressed....only the detail sections are displayed.

So you will have something like this

Detail A {@DisplayLabel} {@DisplayLabel}
Detail B {@DisplayLabel} {@DisplayLabel}

You will have to play around with it but make each section exactly the size to position the label properly...it may be necessary to make a small adjustment from normal at rows 11 and 21 when you start a new page

Now in the conditional suppress for each label you will require a formula...something like this (count the labels L to R)

for label 1 (conditional suppress)

whilePrintingRecords;
if {?StartLabel} > 1 then
True
else
False;

for label 2 (conditional suppress)

whilePrintingRecords;
if {?StartLabel} > 2 then
True
else if {?StartLabel} + (?LabelsWanted} - 1 < 2
True
else
False;

for label 3 (conditional suppress)

whilePrintingRecords;
if {?StartLabel} > 3 then
True
else if {?StartLabel} + (?LabelsWanted} - 1 < 3
True
else
False;

for label 4 (conditional suppress)

whilePrintingRecords;
if {?StartLabel} > 4 then
True
else if {?StartLabel} + (?LabelsWanted} - 1 < 4
True
else
False;

{b} You can see the pattern here for each formula[/b] This is tedious...but with cutting and pasting into the conditional suppress of each label the chore is not too bad.

Now the final step is to enable &quot;suppress blank section&quot; for each detail subsection.

Try this out first on ordinary paper first and overlay a label page to make sure the alignment is fine. Tweak positions and subsection sizes appropriately until it is perfect.

Now you have a crystal report for a max of 60 labels

Jim Broadbent
 
Thank you for all of the replies. I think there is a lot of useful info here that I can use in several situations I am dealing with.
Gladys

Gladys Clemmer

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top