I have a report that exports to PDF with the shipment number as the filename, but I want the file name to include the values from two other fields [CSR] and [facility] in the same query. Nothing I do works. Any Help??
PHP:
Private Sub Command30_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim MyFileName As String
Dim mypath As String
Dim temp As String
mypath = "c:\paf\reports\"
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT [shipment] FROM [headerreportquery]", dbOpenSnapshot)
Do While Not rs.EOF
temp = rs("shipment")
MyFileName = rs("shipment") & ".PDF"
DoCmd.OpenReport "pafreport", acViewReport, , "[shipment]=" & temp & ""
DoCmd.OutputTo acOutputReport, "", acFormatPDF, mypath & MyFileName
DoCmd.Close acReport, "pafreport"
DoEvents
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub