Solved

MS Access VBA to update Adobe form checkbox and radiobuttonlist

Posted on 2013-01-30
10
1,626 Views
Last Modified: 2014-01-22
Hope you can help. I am ok with updating text boxes on an Adobe form via VBA, but not the Radiobutton list. A code sample would be great.

Code segment (text field updates, the checkbox and readiobuttonlist fields do not)

   
    'Update Text Field
    Set field2 = jso.getField("form1[0].#subform[1].#field[16]")
    field2.Value = "Field_16"  ' assign the fields value
   
    'Update Checkbox field
    Set field2 = jso.getField("form1[0].#subform[1].CheckBox1[0]")
    field2.Value = 1  ' assign the fields value

    'Update Radiobuttonlist field
    Set field2 = jso.getField("form1[0].#subform[1].RadioButtonList1[2]")
    field2.Value = 22  ' assign the fields value
   
    'Save the changes to the form
    theForm.Save PDSaveIncremental, cPDF
0
Comment
Question by:Charly999
[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
  • 6
  • 4
10 Comments
 
LVL 57
ID: 38841321
No takers yet?   Let me see if I can't figure it out....

Jim.
0
 
LVL 57
ID: 38841394
Basically the code is sound.  Try passing it as text:

   'Update Checkbox field
    Set field2 = jso.getField("form1[0].#subform[1].CheckBox1[0]")
    field2.Value = "1"  ' assign the fields value

    'Update Radiobuttonlist field
    Set field2 = jso.getField("form1[0].#subform[1].RadioButtonList1[2]")
    field2.Value = "22"  ' assign the fields value

Jim.
0
 

Author Comment

by:Charly999
ID: 38841600
Jim, appreciate the feed back. I have dug deeper, and have found several things:

 1) I can see the updates in the PDF form when I have it open and I'm running the VBA code from MS Access.

  2) Problem seems to be when saving the form, the checkboxes and readiobutton values roll back to the initial values, so the updated values are lost.

  3) Others sites suggest the problem is with the checkboxes and radiobuttons being on the Master page in the pdf document.and therefore can't be updated using the above coding. They suggest using javascript.

So, I have tried javascript and that doesn't seem to be working either. The pdf is created by another group via livecycle, and I can't edit it in to place the controls on a design page.

Any help would be greatly appreciated. If you know the syntax for using javascript to update a specific checkbox on a form, that wouid help.

Thanks

Charly
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 57
ID: 38843828
Your working in a area with PDF's that I've never dealt with, so I really don't have anything to offer.

I'd have to have the PDF your working with and the code and take a stab at it to get anywhere.

Jim.
0
 

Author Comment

by:Charly999
ID: 38852064
Jim, here is code from the net and attached form. Does not seem to want to work. Thanks.


Public Sub Test2FromNet()

Dim FV, fn, txt

Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "Acrobat.exe C:\Temp\TestFile.pdf"
 
  '// Set/Get Acrobat Objects
Set App = CreateObject("AcroExch.App")
Set AVDoc = App.GetActiveDoc
Set PDDoc = AVDoc.GetPDDoc
Set jso = PDDoc.GetJSObject

  '// search for fields and get Name+value
txt = ""
If jso.numFields Then
  For i = 0 To jso.numFields - 1
     txt = ""
     fn = jso.getNthFieldName(i)
     Set f = jso.getField(fn)
     FV = f.Value
     If f.Type = "checkbox" Then
        f.Value = 1
    End If
     txt = txt & fn & "=" & FV & ";"
     'MsgBox (txt)
  Next
Else
  MsgBox ("No fields found")
End If


PDDoc.Save PDSaveIncremental, "C:\Temp\TestFile.pdf"
 
Set AVDoc = Nothing
Set PDDoc = Nothing
Set jso = Nothing

End Sub
0
 
LVL 57
ID: 38852566
Don't see an attachment...

Jim.
0
 

Author Comment

by:Charly999
ID: 38856488
Trying again w attachement. Selecting file from the "Browse" button, Clicking "Attach", seeing the barber pole spin, watching the browser status bar run out. Looks to me like it worked, but maybe not. I'll try again.
0
 

Author Comment

by:Charly999
ID: 38856853
Ok, attached added.
TestFile.pdf
0
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 38857101
Hum, not sure what to tell you.  Code below seemed to work fine here.  Unchecked all the check boxes, save, re-opened and verified saved as un-checked, then ran the code.  All the boxes from "Category(s) of info:" and below were checked.

Jim.

Public Sub Test2FromNet()

Dim wshshell As Object
Dim app As Object
Dim AVDoc As Object
Dim PDDoc As Object
Dim jso As Object
Dim i As Integer
Dim f As Object

Dim FV, fn, txt

Const PDSaveIncremental = 0
 
Const PDSaveFull = 1
Const PDSaveCopy = 2
Const PDSaveLinearized = 4
Const PDSaveWithPSHeader = 8
Const PDSaveBinaryOK = 16
Const PDSaveCollectGarbage = 32
Const PDSaveForceIncremental = 64
Const PDSaveKeepModDate = 128

Set wshshell = CreateObject("Wscript.Shell")
wshshell.Run "Acrobat.exe C:\Temp\TestFile.pdf"
 
'// Set/Get Acrobat Objects
Set app = CreateObject("AcroExch.App")
Set AVDoc = app.GetActiveDoc
Set PDDoc = AVDoc.GetPDDoc
Set jso = PDDoc.GetJSObject

'// search for fields and get Name+value
txt = ""
If jso.numFields Then
  For i = 0 To jso.numFields - 1
     txt = ""
     fn = jso.getNthFieldName(i)
     Set f = jso.getField(fn)
     FV = f.Value
     If f.Type = "checkbox" Then
        f.Value = 1
    End If
     txt = txt & fn & "=" & FV & ";"
     Debug.Print txt
  Next
Else
  MsgBox ("No fields found")
End If

PDDoc.Save PDSaveIncremental, "C:\Temp\TestFile.pdf"

PDDoc.Close
Set PDDoc = Nothing
Set jso = Nothing
Set AVDoc = Nothing
Set app = Nothing


End Sub
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 38857107
I should note however that I have Acrobat Standard installed on the machine I tested this on.

Jim.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

730 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