I would like to design a loop of some sort to iterate through a listbox, print a report as a PDF, and save with a unique name.
Currently, I am clicking a name in a listbox and then clicking a button to run the code below.
The listbox selection passes the value to the textbox "txtEmployeeName", which sets the criteria for the query that populates the report "Sales_Incentive_Report"
Everything in the code above works fine, I'd just rather not click a name and then a button 50+ times to execute this...
Thanks in advance for your help.
Currently, I am clicking a name in a listbox and then clicking a button to run the code below.
The listbox selection passes the value to the textbox "txtEmployeeName", which sets the criteria for the query that populates the report "Sales_Incentive_Report"
Code:
Private Sub btnPrint_PDF_Click()
Dim strDefaultPrinter, stDocName As String
strDefaultPrinter = Application.Printer.DeviceName
stDocName = "Sales_Incentive_Report"
Set Application.Printer = Application.Printers("PDF Printer")
DoCmd.OpenReport "Sales_Incentive_Report", acViewDesign, , , acHidden
Reports!Sales_Incentive_Report.Caption = txtEmployeeName & "_Sales_Incentive_Report"
DoCmd.Close acReport, "_Sales_Incentive_Report", acSaveYes
DoCmd.OpenReport stDocName, acViewNormal
DoCmd.Close acReport, "Sales_Incentive_Report"
End Sub
Everything in the code above works fine, I'd just rather not click a name and then a button 50+ times to execute this...
Thanks in advance for your help.