Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
1,375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

661 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