Quickreport label repeater

I made a delphi 3.o application.
I print records from a query to a quickreport on avery labels (20 labels a sheet).
This works fine.
But, now I want to build an option to print the records from the query more then one time.
Example: In my query I select 3 records. The user can set a counter to (by.exam) 5. Now I want to print 15 labels on one sheet !

I tryed this.

quickreport-'Afterprintdetailband' I set query1.first (or query1.prev). But this does not work.
When the last record is reached the quickreport close and doesn't see the query1.first anymore.
Who is Participating?
classmateConnect With a Mentor Commented:
The QuickReport is a rather stubborn component. If you're sure that you reach eof and timesprinted>0, you might as well stop using data aware labels, and rather browse the table manually.

In the beforeprint of the band, you assign the appropriate strings from the query to regular labels. If you have added the query fields in the datamodule, simply use the desired field object's AsString method.

In AfterPrint of the band you call your query's next method;

In OnNeedData of the report you test on eof and decide wether you want to go call the "first" method.

RichardBorstAuthor Commented:
Edited text of question.
Do you print all the records in the same cycle on the detail band? or is the detail band reprinted for each of the 3 (now 15) records ??

If you print one record for each cycle, you might find the "OnNeedData" event of the report useful; here you set the "moredata" var param to true if you want the print cycle to continue.

The solution to your problem pretty much depends on exactly how you want the records to appear on the paper, so we'll need a closer specification of this.

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.


You could print 5 copies like this LabelReport.PrinterSettings.Copies := 5;

I see two ways to do this:

(1) This could get messy, but I think it is possible --- you can dynamically change the detailband and its contents.  That is, have 20 copies of TQRExpr or TQRLabel or whatever you use ready, and just use one.  If the user selects, for instance 5, use the first 5 copies.  Don't forget to set the height of the detailband and locations of all 5 TQRLabels.  

(2) Have an empty database just for this purpose, whose structure is identical to the original.  After the query, fill in the database with as many duplicate records the user requests.  Then, use QR.  

In any case, as classmate said, it is better if we can see what kind of label you want to print out.  
RichardBorstAuthor Commented:
The database I want to print from is a store with articles. I want to print one article (code + subscripsion) to one label. Each Record (=article, =label) is printed by the detailband in my quickreport. I made 2 columns with 10 recors in each column.

when I said:
LabelReport.PrinterSettings.Copies := 5;
I gues I get 5 sheets. That's not what I want.

I tried This:

procedure TQRLabelsForm.QRLabelsFormNeedData(Sender: TObject;
  var MoreData: Boolean);

iF (timesprinted > 0) and datamodule2.query3.Eof then begin
                                                       moredata := true;
Where timesprinted is 5 in my example.
But the report stops after printeing the 3(in my example) records.
Is there a way to go to the first record when the report reached te last record ?
meant to write "want to call the "first" method".....
RichardBorstAuthor Commented:
Sorry, I mean goods in a wharehouse instead of articles in a store.
RichardBorstAuthor Commented:
This helps me to comnplete my application succesfully.
I brows the query manually. In the wuickreport I make the dataset -property empty. But I will use the database fields in my labels. At alterdetailprint method I give query.next.
At Onneeddata I check on EOF and on timesprinted.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.