Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32

    I have an Odd Question

    Greetings everyone and thank you in advance for any help given to this question. I think its possible to do but unsure how to make it work.



    Scenario

    I have an Access table to track Transmittals to the Customer for a construction firm. I have managed to recreate their form however they can not put comments or sign that copy. What i have been doing is preparing the form twice. this is time consuming especially on multiple projects ran simultaneously. I have Acrobat DC pro and Access 2016.

    My question is can i load that blank PDF already existing document and populate certain fields from the database and then send that form on to the customer for comments and signatures? Seems to me it should be possible as long as the fields on the PDF match the field names on the access table correct?
    attached is their form image and the second screen is my database that i only need to fill out the top section they complete and sign the bottom and page 2 if necessary.



    Click image for larger version. 

Name:	Ex_PDF_FORM.PNG 
Views:	35 
Size:	75.7 KB 
ID:	46039Click image for larger version. 

Name:	capture2.PNG 
Views:	33 
Size:	107.8 KB 
ID:	46040

  2. #2
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32
    So update

    I had found some code on the net that should be able to be tailored to do what i want
    I can now get access to open an pdf existing form but not populate anything on the form.
    part of the code is

    FileNm = "D:\WORK STUFF\FORMS\2021 blanks\Af_3000.pdf" 'File location
    Set gApp = CreateObject("AcroExch.app")


    Set avDoc = CreateObject("AcroExch.AVDoc")
    If avDoc.Open(FileNm, "") Then
    Set pdDoc = avDoc.GetPDDoc()
    Set jso = pdDoc.GetJSObject


    jso.getField("Af_3000[0].Page1[0].COR_GOVT[0]").Value = "COR_GOVT"
    jso.getField("Af_3000[0].Page1[0].CONTRACTOR[0]").Value = "CONTRACTOR"
    jso.getField("Af_3000[0].Page1[0].Date_Submitted[0]").Value = "Date_Submitted"
    pdDoc.Save PDSaveIncremental, FileNm 'Save changes to the PDF document
    pdDoc.Close
    End If

    what i dont understand is why i am getting a runtime 424 error ?! I would think that i have to put the field location in the code so it know where to get data from right?

    I know i am on the right track please help if you can..

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,938
    might help if you a) tell use what error 424 is and b) what line of code is causing the error

  4. #4
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32
    thanks for the reply

    the runtime error 424 "object not found" and when i run the debugger it highlights this Line " jso.getField("Af_3000[0].Page1[0].COR_GOVT[0]").Value = "COR_GOVT"

    Click image for larger version. 

Name:	Capture.PNG 
Views:	24 
Size:	19.9 KB 
ID:	46046
    Last edited by rshaw63; 08-24-2021 at 06:23 AM. Reason: added picture

  5. #5
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32
    As i stated earlier i had renamed the fields on the PDF to match exactly the table fields in the database, so i am not sure why its not pulling the data. the object not found has to be a part of it I am guessing.

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Can you attach an empty PDF? It looks like you are trying to fill the fields with their names instead of their values. If the code runs on a form you might want to try something like this:
    Code:
    jso.getField("Af_3000[0].Page1[0].COR_GOVT[0]").Value = Me.[COR_GOVT] 'where COR_GOVT is a text box on the form bound to the COR_GOVT field
    Also see the link below for some extra info that might help:
    https://answers.microsoft.com/en-us/...e-3c301da5b890

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #7
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32
    I tried to attach the blank PDF however it is larger than the attachment allowance

  8. #8
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32
    So i changed the code like your example and getting the same error . It does not populate the PDF and i get the error message

    Click image for larger version. 

Name:	Capture.PNG 
Views:	22 
Size:	26.2 KB 
ID:	46048

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,563
    Can't you inspect the locals window and see what jso holds?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32
    not sure how to do that can you explain.

    I did however run the code again and i am getting Runtime Error 424 - Object Required Error on this line:
    Click image for larger version. 

Name:	Capture.PNG 
Views:	22 
Size:	24.6 KB 
ID:	46049
    Last edited by rshaw63; 08-24-2021 at 10:27 AM. Reason: More Information

  11. #11
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32
    I know those fields are populated in Access though looking at the table:
    Attachment 46050Attachment 46051

  12. #12
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32
    Update again

    so messing with the code a bit I had managed in the Code Editor to get it to display the proper value from the database field but it still wont put it on the PDF document. Meaning in the debugger window its pulling the values from the database just not putting that value on the pdf form.

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,563
    In the VBA window, put a breakpoint on a line FileNm=
    Then click the button and walk through the code with F8.

    Once you supposedly have created the jso object, inspect it in the Locals window and see what it contains.

    I do not believe the error is complaining about your db fields, but the pdf fields?

    https://community.adobe.com/t5/acrob...a/m-p/10047916
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32
    So i did the breek and step as you mentioned i get a ding from the PC but nothing shows up in the locals window either.
    pretty frustrating I know it should be possible. thank you for your help though.

  15. #15
    rshaw63 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    32
    Okay so stepping through it it is what i guess i am reading has no data in the variable however if you highlight the line in the editor it is pulling the information from the table. so not sure what the deal is

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. SQL Question
    By 9944pdx in forum Queries
    Replies: 13
    Last Post: 07-03-2018, 12:12 PM
  2. Else Question
    By CraigR in forum Access
    Replies: 5
    Last Post: 06-02-2018, 06:21 PM
  3. I have a question
    By azhar2006 in forum Database Design
    Replies: 10
    Last Post: 12-10-2013, 10:56 AM
  4. Replies: 4
    Last Post: 08-25-2012, 07:19 PM
  5. First question
    By FTAUSS in forum Access
    Replies: 4
    Last Post: 01-10-2012, 03:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums