I want to print the multiple copies of data report as shown in the attached picture, its printing only printing only one.
I have created the text box in the form to provide the number of copies named as txtcopies. plz check and resolve
Here is the full coding of that form
Private Sub btnprnt_Click()
Dim qty As Integer
Dim A As Integer
qty = txtcopies.Text
On Error Resume Next
'Check if the barcode field is blank
If txtbarcodes.Text = "" Then
MsgBox "Please enter the barcode", vbInformation, "Barcode Error"
Set ac = New ADODB.Connection
Set ar = New ADODB.Recordset
SQL = "Select *From tblproduct Where Barcode='" & txtbarcodes.Text & "'"
.Open SQL, strConek, adOpenStatic, adLockOptimistic
If .RecordCount >= 1 Then
If !Barcode = txtbarcodes.Text Then
SQL = "Select *From tblproduct where Barcode= '" & txtbarcodes.Text & "'"
.Sections("Section1").Controls.Item("txtDescription").Caption = !Description
.Sections("Section1").Controls.Item("txtUnitPrice").Caption = !UnitPrice
Set .Sections("Section1").Controls.Item("Image1").Picture = LoadPicture(App.Path & "\Barcodes\" & txtbarcodes & ".jpg")
For A = 1 To qty
Call printbarcode.PrintReport(False, rptRangeAllPages)
MsgBox "Barcode not found", vbInformation, "Record not found"
MsgBox "No product exist in database", vbInformation, "Record not found"
I did not see where you were setting the qty before but now I do. At a glance what is there looks like it should work but then again I use a different report tool and have never used the one built into VB.
I would think that you should be able to specify the number of copies when it is sent to the printer.
This question was cross posted on VBForums where there has been a bit more info uncovered. As far as I can tell rather than printing multiple copies of the report what he was to do is print a variable number of barcode labels on the same page. Calling print in a loop will not solve this issue unless he uses a roll of labels on a label printer where each label counts as a page. To do this on a full size page the report will have to be designed to print a page full of labels with the same value or he will have to write code behind the report to populate the values. Otherwise would have to abandon the report and use the printer object setting current x and y values to print in the proper locations.