Results 1 to 5 of 5
  1. #1
    timesscript is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    34

    Hyperlink to file in text box not opening

    I have a form with a textbox. The textbox displays records of the type "hyperlink" and they are file paths that are selected using VBA FileDialog. In form view it appears as a hyperlink, and on mouseover I get the "hand" cursor, but when I click, nothing opens.



    Any ideas?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    That's because they aren't really hyperlinks, just text strings. If you want a true hyperlink then must use Hyperlink type field and the hyperlink dialog box to populate field. Otherwise, need code to take the text string and act on it as a hyperlink. That's what the intrinsic FollowHyperlink method is for. I just tried using FollowHyperlink in a new db to open PDF files. Crashes my system. Very odd because it used to work with Windows XP and Access 2007 on 32-bit PC. So I switched to Shell method.

    Code:
    Private Sub tbxLinkToFile_Click()
    On Error GoTo ErrProc
    'FollowHyperlink is not working properly
    ''Application.FollowHyperlink Me.tbxLinkToFile
    If Dir(Me.tbxLinkToFile, vbArchive) = "" Then
        MsgBox "File path not found."
    Else
        Dim wsShell As Object
        Set wsShell = CreateObject("WScript.Shell")
        wsShell.Run Chr(34) & Me.tbxLinkToFile & Chr(34)
    End If
    ExitProc:
    Exit Sub
    ErrProc:
    MsgBox "Cannot open document. Contact database administrator. : " & Err.Number
    End Sub
    Review:
    http://www.allenbrowne.com/casu-09.html
    http://allenbrowne.com/func-GoHyperlink.html
    Unfortunately, the Allen Browne GoHyperlink function still uses FollowHyperlink method.
    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.

  3. #3
    timesscript is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    34
    Where would I put your code to make it act like a hyperlink? i.e. what will trigger the code?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    What I show is the Click event for textbox tbxLinkToFile. The textbox displays the file path.
    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.

  5. #5
    timesscript is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    34
    Thanks June7. This answered my question!

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

Similar Threads

  1. Creating a hyperlink to open a pdf file
    By Jrw76 in forum Access
    Replies: 10
    Last Post: 01-24-2014, 09:42 AM
  2. Hyperlink to Picture opening in IE
    By powderhoundbrr in forum Access
    Replies: 2
    Last Post: 03-13-2013, 12:29 PM
  3. Replies: 8
    Last Post: 11-06-2012, 03:41 PM
  4. Replies: 9
    Last Post: 05-07-2012, 06:11 PM
  5. How To View Hyperlink For Attachment File
    By treyprice in forum Access
    Replies: 0
    Last Post: 07-28-2009, 12:51 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