Results 1 to 7 of 7
  1. #1
    Wrightie is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Nov 2017
    Posts
    3

    PDF display in tab form

    I have a tab control form containing 4 tabs.
    On the first tab I have all my general info including an ID field.


    On the other tabs the ID is linked and displays a PDF relating to that ID. The pdf location path is in the table. I've used a webBrowser control. The control source is the table field.

    This all works fine when I click through the tabs the pdfs display. The issue I have is when I click back to a tab that I've already viewed the pdf doesn't display again.

    TIA

    wrightie

  2. #2
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    You may need to requery the tab within the GotFocus Event.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    I prefer this method... the user can open the pdf in a full pdf window. (and any other document)

    paste this code into a module. (ctl-F11, insert , module)
    Then it will open ANY file via its extension....
    .pdf files will open in acrobat,
    .doc files in word
    etc


    USAGE:
    OpenNativeApp "c:\folder\file.xls"
    'opens in excel
    or
    OpenNativeApp field
    'opens item in field in native app


    Code:
    Option Compare Database
    Option Explicit
    
    
    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

  4. #4
    Wrightie is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Nov 2017
    Posts
    3
    Unfortunately Me.Requery doesn't work also tried refresh on the GotFocus Event.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Did a quick test with a static ControlSource for the web browser. First click on the PDF tab and the PDF displays, click another tab and then back to the PDF tab and it is blank. I click RefreshAll from the ribbon and the PDF displays.

    Tried Tab and Page OnClick events and they don't run. The Tab OnChange event does run. However, cannot find any vba or macro equivalent for the RefreshAll. Tried: DoCmd.RunCommand acCmdRefresh, SendKeys "+({f9})", and Me.WebBrowser71.Requery.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

  7. #7
    Wrightie is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Nov 2017
    Posts
    3
    Thanks for all the help.
    Used DoCmd.Requery on the OnChange event

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

Similar Threads

  1. Replies: 3
    Last Post: 01-05-2016, 12:25 PM
  2. Replies: 3
    Last Post: 10-28-2015, 12:38 PM
  3. Replies: 3
    Last Post: 03-17-2014, 10:23 AM
  4. Display info from parent form in child form
    By Leonidsg in forum Forms
    Replies: 3
    Last Post: 03-23-2013, 07:14 PM
  5. Replies: 6
    Last Post: 11-17-2011, 10: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