hi,
this code puts pdf reports into a folder
I am prompted for a number via the query I run
because I have more than one report the query asks me 3 times
could this be modified so I only get prompted once for all the reports in the code
thanks
steve
this code puts pdf reports into a folder
I am prompted for a number via the query I run
because I have more than one report the query asks me 3 times
could this be modified so I only get prompted once for all the reports in the code
Code:
On Error GoTo Err_Handler
Const FOLDER_EXISTS = 75
Const MESSAGE_TEXT1 = "No current invoice."
Const MESSAGE_TEXT2 = "No folder set for storing PDF files."
Dim strFullPath As String
Dim varFolder As Variant
If Not IsNull([Invoice].[Form]![Invoiceno]) Then
' build path to save PDF file
' varFolder = "C:\Users\User\Documents"
varFolder = DLookup("Folderpath", "pdfFolder")
If IsNull(varFolder) Then
MsgBox MESSAGE_TEXT2, vbExclamation, "Invalid Operation"
Else
' create folder if does not exist
varFolder = varFolder & "\" & Me.[CustomerName]
MkDir varFolder
strFullPath = varFolder & "\" & "Invoice Number" & " " & [Invoice].[Form]![Invoiceno] & ".pdf"
' ensure current record is saved before creating PDF file
Me.Dirty = False
DoCmd.OutputTo acOutputReport, "Invoice report", acFormatPDF, strFullPath
strFullPath = varFolder & "\" & "C of C No" & " " & [Invoice].[Form]![Invoiceno] & ".pdf"
' ensure current record is saved before creating PDF file
Me.Dirty = False
DoCmd.OutputTo acOutputReport, "C OF C report", acFormatPDF, strFullPath
strFullPath = varFolder & "\" & "Despatch No" & " " & [Invoice].[Form]![Invoiceno] & ".pdf"
' ensure current record is saved before creating PDF file
Me.Dirty = False
DoCmd.OutputTo acOutputReport, "Invoice delivery note", acFormatPDF, strFullPath
End If
Else
MsgBox MESSAGE_TEXT1, vbExclamation, "Invalid Operation"
End If
Exit_Here:
Exit Sub
Err_Handler:
Select Case Err.Number
Case FOLDER_EXISTS
Resume Next
Case Else
MsgBox Err.Description
Resume Exit_Here
End Select
steve