title: Fill a PDF Form from MS Access
body: <p>I found a post on <a href="https://stackoverflow.com/questions/13362014/fill-in-a-pdf-form-from-vba-ms-access">here</a> on how to fill a fillable PDF from from MS Access.</p>
  <p>It is a Visual Basic code for filling out a fillable PDF.  I have been using Excel to perform this function and would like to migrate my database to Access and still keep the same functionality.  I have figured out how to add my VB code to the button but when I click it gives me and error.  Any help that can be giving would be greatly appreciated.</p>
  <p>I have Adobe Acrobat X Pro and MS Access 2010.  My PDF files was created in word and then converted to a PDF file, I know all my field names because I created them.  The PDF document is saved as c:\CX.pdf, it has 9 pages, some examples of field names on the document are: “Plant Name”, “Station Location”, “Installer or Owner”.  My MS Access Data Base Fields are named the same.</p>
  <pre><code>Option Compare Database
  
  Private Sub Command105_Click()
  
  Dim FileNm, gApp, avDoc, pdDoc, jso
  
  FileNm = &quot;c:\CX.pdf&quot; 'File location
  Set gApp = CreateObject(&quot;AcroExch.app&quot;)
  
  Set avDoc = CreateObject(&quot;AcroExch.AVDoc&quot;)
  If avDoc.Open(FileNm, &quot;&quot;) Then
      Set pdDoc = avDoc.GetPDDoc()
      Set jso = pdDoc.GetJSObject
  
      jso.getField(&quot;CX[0].Page1[0].Plant_Name[0]&quot;).Value = &quot;Plant_Name&quot;
      jso.getField(&quot;CX[0].Page1[0].Station_Location[0]&quot;).Value = &quot;Station_Location&quot;
      jso.getField(&quot;CX[0].Page1[0].Installer_or_Owner[0]&quot;).Value = &quot;Installer_or_Owner&quot;
      pdDoc.Save PDSaveIncremental, FileNm 'Save changes to the PDF document
      pdDoc.Close
      End If
  'Close the PDF; the True parameter prevents the Save As dialog from showing
  avDoc.Close (True)
  
  'Some cleaning
  Set gApp = Nothing
  Set avDoc = Nothing
  Set pdDoc = Nothing
  Set jso = Nothing
  
  End Sub
  </code></pre>
  <p>It was giving me the error &quot;Object not found&quot;, now it's not giving me error but it's still not writing to the PDF.</p>