Form to PDF

fenhow

Registered User.
Local time
Today, 02:30
Joined
Jul 21, 2004
Messages
599
Hi, I have this working code to create a PDF document from a form. It works excellent.

What I am trying to do is create several documents vs one at a time. I have a form with all pertinent data but it is a Continuous Form say with 10 records in it.

I want to be able to generate a PDF with 10 pages or 10 PDFs one for each record on the form. Right now I have a button that when clicked runs the code below and creates the PDF that the form is currently focused on.

With the code below is there a way to accomplish this? or does anyone have any alternative solutions like a macro idea or something? Can I add some kind of loop code or something?

Many thanks.
Fen

Private Sub Command74_Click()
'DriveNow Lease PDF
'theDBguy@gmail.com
'4/10/2012

'This demo creates a XFDF file to merge with a fillable PDF form.
'Using this method avoids the need to use an Acrobat DLL to manipulate the PDF file.
'This method relies on the capabilities of the installed PDF reader.

'Declare the PDF file to be filled and assume it's in the same directory as the database
Const strPDF As String = "DN_Default_Letter_PDF_2016.pdf"

'Declare the XFDF file to use
Const strXFDF As String = "DN_Default_Letter_PDF_2016.xfdf"

Dim strPath As String
Dim intFile As Integer

strPath = "T:\CAM360_AUTOGEN_DOCUMENTS"
intFile = FreeFile

'Create XFDF file
Open strPath & "\" & strXFDF For Output As #intFile

Print #intFile, "<?xml version=""1.0"" encoding=""UTF-8""?>"
Print #intFile, "<xfdf xmlns=""http://ns.adobe.com/xfdf/"" xml:space=""preserve"">"
Print #intFile, "<f href=""" & strPDF & """/>"
Print #intFile, "<fields>"

Print #intFile, "<field name=""CUSTOMER"">"
Print #intFile, "<value>" & [Forms]![frm_Delinquency_Auto]![FullName] & "</value>"
Print #intFile, "</field>"


Print #intFile, "<field name=""ADDRESS"">"
Print #intFile, "<value>" & [Forms]![frm_Delinquency_Auto]![Address] & "</value>"
Print #intFile, "</field>"

Print #intFile, "<field name=""LEASEDATE"">"
Print #intFile, "<value>" & [Forms]![frm_Delinquency_Auto]![LoanDate] & "</value>"
Print #intFile, "</field>"

Print #intFile, "</fields>"
Print #intFile, "</xfdf>"

Close #intFile

'Open the PDF file
ShellEx strPath & "\" & strXFDF
End Sub
 
Loop through the forms recordsetclone, which will contain the 10 records

'--Put first part of your xml file generation here

with me.recordsetclone
.movefirst
do while not .eof
Print #intFile, "<field name=""CUSTOMER"">"
Print #intFile, "<value>" & ![FullName] & " </value>"
Print #intFile, "</field>"

.............
.................
.movenext
loop
end with
 

Users who are viewing this thread

Back
Top Bottom