Import data from textbox into table (1 Viewer)

mounty76

Registered User.
Local time
Today, 00:04
Joined
Sep 14, 2017
Messages
341
Code:
'theDBguy's PDF Form Fields Demo
'accessmvp.com/thedbguy
'9/24/2017
'v1.0
'Demonstrates how to get a list of form field names from a fillable PDF form.
'-
'Copyright Notice
'This demo was originally created by theDBguy@gmail.com.
'You are free to use any code from this demo, provided you also include
'the following copyright notice wherever you use the code in your application.
'-
'Copyright Notice: The following code was originally written by theDBguy@gmail.com.
'You are free to use this code in your application, provided this copyright notice remains unchanged. All rights reserved."

Private Sub cmdDoSomething_Click()
On Error GoTo errHandler

Dim appAcro As Object
Dim docAcro As Object
Dim docPD As Object
Dim jso As Object
Dim fd As Object
Dim strFile As String
Dim lngCounter As Long

Set fd = Application.FileDialog(3) 'filepicker

'select PDF file
With fd
    .AllowMultiSelect = False
    .Filters.Clear
    .Filters.Add "PDF Files", "*.pdf"
    .Title = "Locate PDF file"
    If .Show Then
        strFile = .SelectedItems(1)
        Me.lblFilePath.Caption = strFile
        
        Set appAcro = CreateObject("Acroexch.AVDoc")
        If appAcro.Open(strFile, "") Then
            Set docPD = appAcro.getPDDoc()
            Set jso = docPD.getJSObject
            
            'clear previous field list
            Me.txtFields = Null
            
            If jso.numFields > 0 Then
                For lngCounter = 0 To jso.numFields - 1
                    Me.txtFields = Me.txtFields & jso.getNthFieldName(lngCounter) & vbCrLf
                    
                Next
                MsgBox "Done!", vbInformation, "Demo"
                
            Else
                MsgBox "No form fields found!", vbInformation, "No Fields"
                
            End If
            'Close the PDF; the True parameter prevents the Save As dialog from showing
            appAcro.Close True
            
        Else
            'unexpected Acrobat error
            MsgBox "There was a problem reading the PDF file.", vbInformation, "Error"
            
        End If
        
    End If
    
End With

errExit:
    'cleanup
    Set fd = Nothing
    Set jso = Nothing
    Set docPD = Nothing
    Set docAcro = Nothing
    Set appAcro = Nothing
    Exit Sub
    
errHandler:
    MsgBox Err.Number & ": " & Err.Description
    Resume errExit
    
End Sub

Private Sub Form_Open(Cancel As Integer)

Me.lblTitle.Caption = cDemoTitle & vbCrLf & cDemoVersion

End Sub

Private Sub txtEmail_Click()

Me.cmdFocus.SetFocus
ShellEx "http://www.accessmvp.com/thedbguy"

End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:04
Joined
Oct 29, 2018
Messages
21,473
Me.txtFields = Me.txtFields & jso.getNthFieldName(lngCounter) & vbCrLf
Thanks. Try changing the above code to this:
Code:
Me.txtFields = Me.txtFields & jso.getNthFieldName(lngCounter).Value
 

mounty76

Registered User.
Local time
Today, 00:04
Joined
Sep 14, 2017
Messages
341
I get an error 424: Object required. Ideally I'd also like to pull out the field title from the PDF so in the access textbox it would read

First Name: Joe Bloggs
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:04
Joined
Oct 29, 2018
Messages
21,473
I get an error 424: Object required. Ideally I'd also like to pull out the field title from the PDF so in the access textbox it would read

First Name: Joe Bloggs
See if you get any errors running the attached.
 

Attachments

  • theDBguyPDFFormFieldsDemoV1.2.zip
    42.5 KB · Views: 72

mounty76

Registered User.
Local time
Today, 00:04
Joined
Sep 14, 2017
Messages
341
Perfect!! Thank you very much!! Works great, much better solution for me, thanks again
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:04
Joined
Oct 29, 2018
Messages
21,473
Perfect!! Thank you very much!! Works great, much better solution for me, thanks again
You're welcome. Glad we could assist. Good luck with your project.
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:04
Joined
Sep 21, 2011
Messages
14,299
That would be an Insert query?
 

Users who are viewing this thread

Top Bottom