First of all, I barely use Access and I'm very much a novice so I hope I explain this correctly so it makes sense.
I have a very small database created just for the purpose of easy formatting a report and printing the report to PDF for management. I have everything set up and everything is working great, except I would like to be able to route the report when saving to a folder based on the values of list boxes.
I have a form with 3 list boxes that cascade or depend on values on the preceding one. The first box is "lstDivision", when selected it drills down and shows the values for "lstDivRep" and 3rd is "lstAssociate". I currently have all of the files so they will save to PDF in a local folder. What I'd like to do is set this up so it will route to sub-folders based on the values selected in the first two list boxes. (Hope this makes sense). The "lstAssociate" is multi-selection list box.
Here is the code I have now:
Private Sub btnSaveToPDF_Click()
Dim sReportName As String
sReportName = "IDP" '' name of the predefined report
Dim vItm As Variant
Dim sSQL As String
For Each vItm In [Forms]![IDP]![lstAssociate].ItemsSelected
sSQL = "[Associate] = '"
sSQL = sSQL & [Forms]![IDP]![lstAssociate].ItemData(vItm) & "'"
DoCmd.OpenReport sReportName, acViewPreview, , sSQL
DoCmd.OutputTo acOutputReport, "", acFormatPDF, "C:\Users\Daniel\Desktop\backup copy\New Output\" & [Forms]![IDP]![lstAssociate].ItemData(vItm) & " - " & [Forms]![IDP]![lstDivision].ItemData(vItm) & " - Updated (" & Format(Date, "mm-dd-yyyy") & ")" & ".PDF", False
DoCmd.Close acReport, sReportName
Next vItm
End Sub
Any help would be greatly appreciated because I've been searching off and on for 3 days.
Thanks, Dan