Solved

How do I merge data from access to a pdf form? I have other PDF related questions too.

Posted on 2006-11-01
7
1,367 Views
Last Modified: 2010-09-14

I'm familiar with Access, however, I know very little about PDFs, and how to merge Access data onto them. I'm currently using Access 2003 and Adobe Acrobat Professional 7.0. I would prefer not to purchase a 3rd party software if I don't have to.

Currently I have several stand alone Fillable pdf forms that the users fill out and save. What I want to do is prepolulate most of data for them from an Access database.  

Here are some of the questions I have:
1. How do I filter out just the record they want? Can you link a PDF to a parameter query?
2. If I have 50 records in my access table, how do I merge all 50 records to an exisiting pdf form? Like a Word mail merge.
3. Once the merge is complete, can you save the new merged pdf so that it is no longer attached to the database?

Thanks for all of your help. I appreciate it. Please include code samples if appropriate.  
0
Comment
Question by:NLGroup
  • 3
  • 2
7 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 17856806
Do all 50 records go into the forms creating 50 forms - if so, do you have a naming convention for them?

The code itself is not too difficult, and I'm guessing you keep a blank form as a master, populate with record 1 and save to a name, then loop to 2 etc....


Kelvin
0
 

Author Comment

by:NLGroup
ID: 17857476
Kelvin, thanks for your response.

I was thinking of just merging them and printing them. I had not thought about saving them.

Right now, my one PDF is linked to the table with the 50 records. I linked it with the Forms Designer. Can I just merge and print?
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 17861466
If you have the blank pdf with the fields on it, the you can, with the use of a bit of code, populate the fields and print them. In all cases where I've done it before, we had to keep a copy so, they we saved first. In that case, we even went as far as creating the field on a blank pdf, then populating them.

Kelvin
0
 

Author Comment

by:NLGroup
ID: 17865935
Do you have some sample code?
0
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 500 total points
ID: 17869605
You need to set references to Adoble type libraries. When I did this last it was adobe 5.0 and they were set to the Adobe Acrobat 5.0 Type library  and AFormAut 1.0 Type library (in the Reader plugins folder somewhere)

Function would go something like this

Note thios piece of code was to add a new field - you may want to edit an existing field

    Dim PDDoc As CAcroPDDoc
    Dim formApp As AFORMAUTLib.AFormApp
    Dim acroForm As AFORMAUTLib.Fields
    Dim field As AFORMAUTLib.field
    Dim AVDoc As CAcroAVDoc
    Dim bOk As Boolean

    Set AVDoc = CreateObject("AcroExch.AVDoc")
    While Not bOk
        bOk = AVDoc.Open(sFileName, "")
    Wend
   
    Set PDDoc = AVDoc.GetPDDoc
    Set formApp = CreateObject("AFormAut.App")
    Set acroForm = formApp.Fields
   
    Set field = acroForm.Add(sFieldName, "text", 0, 0, 35, 510, 0)
    field.IsHidden = False
    field.Value = sFieldValue  'parameter with test field's data
    field.TextSize = "9"
    field.TextFont = "Arial"
       
    If Not PDDoc.Save(PDSaveFull, sFileName) Then
        MsgBox "Unable to Save the PDF file (" & sFileName & ")"
    End If
   
    If Not AVDoc.Close(True) Then
        MsgBox "Unable to close the PDF file (" & sFileName & ")"
    End If

ex:
    Set PDDoc = Nothing ' Free the called object
    Set formApp = Nothing
    Set acroForm = Nothing
    Set field = Nothing
    Set AVDoc = Nothing
    Exit Sub
er:
    GoTo ex
    Exit Sub


0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now