Results 1 to 3 of 3
  1. #1
    zane2g is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2020
    Posts
    2

    PDF Docs in Access

    Good morning all,


    I'm new to this forum so apologies if this question has been asked before.
    Basically , what I have is a number of editable pdf forms (approx. 6).
    What I would like to do is create an access database where I have a front screen that will show buttons to access each of the forms.
    You will then be able to fill in each of the forms and once complete the forms can be saved in the data base and also printed.

    Can any one point me to some instruction / training videos or even be able to explain how I can do this.

    Many thanks
    Zane

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Store the pdfs in folders, NOT in the db, since it will fill it up fast.
    instead store the path of the file in the table, then you can use the routine below to open the pdf.

    Paste this code into a module, and it will open ANY file in its native application.
    In a form put the field and a button to open it.


    if the file is myFile.pdf, will open it in acrobat
    if the file is myFile.doc, it will open the doc in Word
    if its just a file path, it will open in file explorer.
    etc..

    usage:
    OpenNativeApp txtBox



    paste this code into a module
    Code:
    'Attribute VB_Name = "modNativeApp"
    'Option Compare Database
    Code:
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Const SW_SHOWNORMAL = 1
    Const SE_ERR_FNF = 2&
    Const SE_ERR_PNF = 3&
    Const SE_ERR_ACCESSDENIED = 5&
    Const SE_ERR_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    Const SE_ERR_ASSOCINCOMPLETE = 27&
    Const SE_ERR_DDETIMEOUT = 28&
    Const SE_ERR_DDEFAIL = 29&
    Const SE_ERR_DDEBUSY = 30&
    Const SE_ERR_NOASSOC = 31&
    Const ERROR_BAD_FORMAT = 11&
    
    Public Sub OpenNativeApp(ByVal psDocName As String)
    Dim r As Long, msg As String
    r = StartDoc(psDocName)
    If r <= 32 Then
        'There was an error
        Select Case r
            Case SE_ERR_FNF
                msg = "File not found"
            Case SE_ERR_PNF
                msg = "Path not found"
            Case SE_ERR_ACCESSDENIED
                msg = "Access denied"
            Case SE_ERR_OOM
                msg = "Out of memory"
            Case SE_ERR_DLLNOTFOUND
                msg = "DLL not found"
            Case SE_ERR_SHARE
                msg = "A sharing violation occurred"
            Case SE_ERR_ASSOCINCOMPLETE
                msg = "Incomplete or invalid file association"
            Case SE_ERR_DDETIMEOUT
                msg = "DDE Time out"
            Case SE_ERR_DDEFAIL
                msg = "DDE transaction failed"
            Case SE_ERR_DDEBUSY
                msg = "DDE busy"
            Case SE_ERR_NOASSOC
                msg = "No association for file extension"
            Case ERROR_BAD_FORMAT
                msg = "Invalid EXE file or error in EXE image"
            Case Else
                msg = "Unknown error"
        End Select
    '    MsgBox msg
    End If
    End Sub
    
    Private Function StartDoc(psDocName As String) As Long
    Dim Scr_hDC As Long
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
    End Function

    usage:

    Code:
    sub btnOpenFile_click()
      OpenNativeApp ME.txtBox
    end sub



  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Some info about fillable PDF forms and Access (a Google search will return many more):
    http://www.utteraccess.com/forum/ind...wtopic=2034131

    It would be much easier of you would create in your new Access database some basic data entry forms and recreate your existing PDFs as Access reports that you then can save as PDFs with ranman256's code.

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

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 08-09-2019, 12:27 PM
  2. Import all excel docs in a folder into access with VBA?
    By snipe in forum Import/Export Data
    Replies: 3
    Last Post: 05-09-2014, 01:58 PM
  3. Google docs & email
    By Historypaul in forum Import/Export Data
    Replies: 0
    Last Post: 02-17-2013, 10:51 PM
  4. Generate docs from MS access
    By matspring in forum Access
    Replies: 2
    Last Post: 05-07-2011, 07:48 PM
  5. word docs.
    By laqsb in forum Access
    Replies: 1
    Last Post: 02-26-2010, 08: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