Print Current Form to PDF

Gr4nt1y

New member
Local time
Today, 07:20
Joined
Sep 20, 2019
Messages
7
Please can someone help me
the issue I am currently having is saving a individual record as a filled out form to pdf
I can get it to print of as a single form and then save to pdf but I would like it to save to pdf in the desired folder automatically. The Code I am using is:

Private Sub Save_Click()
Dim FileName As String
Dim FilePatch As String
FileName = "Order_No_" & Me.Order_Number
Filepath = "C:\Users\Name\Documents\Order System\Receipt" & FileName & ".pdf"
'DoCmd.OutputTo acOutputForm "Receipt", acFormatPDF, Filepath
DoCmd.OutputTo acOutputForm, "Receipt", acFormatPDF, Filepath
DoCmd.Save acForm, "Receipt"
DoCmd.Close acForm, "Receipt"
End Sub
 
not sure what your question is - is it you want to change this automatically to something else?

C:\Users\Name\Documents\Order System

Or do you mean some other event rather the click event of a button?
 
Code:
Private Sub Save_Click()
Dim FileName As String
Dim FilePatch As String
FileName = "Order_No_" & Me.Order_Number
Filepath = "C:\Users\Name\Documents\Order System\Receipt" & FileName & ".pdf"
Forms("Receipt").Filter = "[Order Number]='" & Me![Order Number] & "'"
Forms("Receipt").FilterOn = True
DoCmd.OutputTo acOutputForm, "Receipt", acFormatPDF, Filepath
'DoCmd.Save acForm, "Receipt"
DoCmd.Close acForm, "Receipt", acSaveNo
End Sub
 
not sure what your question is - is it you want to change this automatically to something else?

C:\Users\Name\Documents\Order System

Or do you mean some other event rather the click event of a button?


hopefully to be able to save one receipt at a time to a folder in pdf format.
when I save to pdf it saves of the records in 1 pdf file, but I can print of the receipts individually using a button
 
Code:
Private Sub Save_Click()
Dim FileName As String
Dim FilePatch As String
FileName = "Order_No_" & Me.Order_Number
Filepath = "C:\Users\Name\Documents\Order System\Receipt" & FileName & ".pdf"
Forms("Receipt").Filter = "[Order Number]='" & Me![Order Number] & "'"
Forms("Receipt").FilterOn = True
DoCmd.OutputTo acOutputForm, "Receipt", acFormatPDF, Filepath
'DoCmd.Save acForm, "Receipt"
DoCmd.Close acForm, "Receipt", acSaveNo
End Sub


Thank you very much this worked straight away :)
 

Users who are viewing this thread

Back
Top Bottom