Results 1 to 10 of 10
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    dblClick textbox to follow hyperlink

    i have a table where the user enters, along with a few other items, a hyperlink to a related file (on the company server); (typically a *.pdf or *.jpg)
    On an associated form, rather than display the full path of the hyperlink, i provide a textbox with only the actual file name.
    Code:
                    vFileName = Trim(.SelectedItems.Item(1))   'contains the hyperlink path
                    strFileName = Mid(filename, InStrRev(vFileName, "\", -1, vbTextCompare) + 1)
    I need to find a way to allow the user to open the hyperlink through this textbox (with strFileName as its ControlSource.
    (as a check, I added a textbox that does have the hyperlink field as its source, and clicking on that control does open the link )

    using this code, i instead get: ERROR7971

    Code:
    Private Sub txtlinktoContractDoc_DblClick(Cancel As Integer)
    On Error GoTo Error_linktoContractDoc
    Dim strHyperLink As String
    
        strHyperLink = DLookup("linktoContractDoc", "tbeProjectInfo_ContractDocs", "ContractID like '" & Me.txtContractID & "'")
        Application.FollowHyperlink strHyperLink, , True
    
    Error_linktoContractDoc:
        MsgBox Err & ": " & Err.Description
    End Sub
    any thoughts and/or suggestion will be greatly appreciated in advance,
    m.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    And what is error 7971 ?
    Put a debug.print before the application line and see what is returned.
    Don't just assume you have it working? Check each step.

    Basic debugging 101.

    An ID in a name indicates to me when I use it, that the field/variable is numeric, in which case do not use single quotes, they are for text.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    I added a textbox that does have the hyperlink field as its source, and clicking on that control does open the link
    Wouldn't it be easier to hide the textbox bound to the full hyperlink then simply use it in the double-click event of the other one:
    Code:
    Application.FollowHyperlink Me.txtFullHyperLinkHidden, , True
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Someone passed on a tip to get a filename from a path very easily.
    I tried it and it appeared to work?

    strFileName = Dir(YourVerylongWindedPathToFile)
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    i like your approach a lot.
    oddly, Me.txtFullHyperLinkHidden returns the value with a leading #, and a following "1" - not certain what that is all about (that's for another time...)

    adjusting the formula to be:

    Code:
    Application.FollowHyperlink Mid(Me.txtFullHyperLinkHidden, 2, Len(Me.txtFullHyperLinkHidden) -1), ,True
    WORKS just fine

    thnx,
    m

  6. #6
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    error 7971 is: "Microsoft Office Access can't follow the hyperlink to..."
    had been stepping through; was getting as far as the MS$oft "some ... contain... do you want to open...", before the error occured

    i do get that typically an ID is a number; in this particular instance, alpha characters are part of the ID (22-1234a)


    thnx for the attention,
    m.

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Glad to hear, I think it might be safer to try using the HyperlinkPart method to extract the address:

    Code:
    Application.FollowHyperlink HyperlinkPart(Me.txtFullHyperLinkHidden,acAddress), ,True
    https://docs.microsoft.com/en-us/off....hyperlinkpart

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

  8. #8
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    OOOO

    dir() <-- things you've never know about !! THNX !!!

  9. #9
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    HyperLinkPart...

    I had read some about the associated problem, but most went onto far more complicated approach to deal with.
    yeah... inversely, this is so much simpler

    big THNX !

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Follow Hyperlink Method
    By philip.mccollum in forum Access
    Replies: 1
    Last Post: 07-08-2015, 05:57 AM
  2. show usename when textbox is dblclick
    By pimpzter in forum Access
    Replies: 3
    Last Post: 09-25-2014, 07:00 PM
  3. Add button to follow hyperlink in table
    By stanley721 in forum Forms
    Replies: 6
    Last Post: 06-22-2013, 08:49 AM
  4. Adding Hyperlink into Textbox with Text
    By tylerg11 in forum Forms
    Replies: 5
    Last Post: 11-07-2011, 01:58 PM
  5. Replies: 0
    Last Post: 05-16-2008, 07:50 AM

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