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

Print report with number of copies inputed by user

Status
Not open for further replies.

KTB23

MIS
Jul 7, 2003
12
US
I have one form where you input customer information, and then another main form, with a command button which prints the report of all of the new customer information inputed onto labels. I am trying to add a list box to the customer info form for the desired number of copies to print of that particular label, so that when you click on the command button to print on the main form, it prints the specified number for each label (which may be different for each customer) from that list box. But... I can't get it to work. I was trying to do it with a macro using both OpenReport & PrintOut, but I'm not sure that PrintOut let's you use a variable? Does anyone have any ideas on how to go about this?

Thanks in advance!
 
one method would be to create a table to store the data in, and add a new record for each label you want printed. The number of labels being selected by the ListBox. You can put the ListBox and the CommandButton on the same Form you use for the Input of Data, just place them in the Header or Footer Section. In the AfterUpdate event for the ListBox add code to delete the existing data in the table, loop through and add the new data until reaching the value in the ListBox as in this example,which by the way was made using 2 forms, one with the data and one with the ListBox. Just drop the forms!FormName. from the code if you do it all on one form.:

Private Sub lstCopies_AfterUpdate()
DoCmd.SetWarnings False
DoCmd.RunSQL ("Delete * From tblNewEmp")
DoCmd.SetWarnings True
Dim db As DAO.database, rst As DAO.Recordset
Dim x As Integer
x = 0
Set db = CurrentDb
Set rst = db.OpenRecordset("tblNewEmp")

Do While x < Val(Nz([lstCopies], 0))
With rst
.AddNew
!EmployeeID = forms!frmNewEmp.txtID
!LastName = forms!frmNewEmp.txtLN
!FirstName = forms!frmNewEmp.txtFN
!TitleOfCourtesy = forms!frmNewEmp.txtTOC
!HireDate = forms!frmNewEmp.txtHD
.UPDATE
End With
x = x + 1
Loop
Set db = Nothing
Set rst = Nothing

End Sub

Then all you have to do is use this table as the label report input, and you should get the proper amount of labels.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top