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,368 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

895 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

16 Experts available now in Live!

Get 1:1 Help Now