Results 1 to 5 of 5
  1. #1
    Pbear88 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    26

    Launching a hyperlink from text box field

    I'm trying to create a field on a form that launches a value that I want Access to treat like a hyperlink. I know I could create a hyperlink field type in the table, but since I'm eventually going to put this table into SQL Server, I wanted to have the field type something that can be stored in the new table format. I have created a text box field [MyhyperlinkField] on a form that displays the value from the table. The value is a path to a file on my computer (i.e. G:\documents\.....). I have changed the properties in this text box to Hyperlink-yes, and Display as Hyperlink-Always. When I run the form, and click on the blue, underlined value, it does not launch the hyperlink. Obviously, I'm missing some code. I've tried to research FollowHyperlink and GoHyperlink methods, but I couldn't follow where I should be putting this method, and didn't understand the proper syntax to launch my path that is displayed in the text box.



    Thanks for any suggestions

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Use the textbox Click event. Select [Event Procedure] in the event property and click the ellipsis to open the VBA editor. Type FollowHyperlink code into the procedure.

    Or if you are using Allen Browne's GoHyperlink function, it should handle structuring the path into a correct hyperlink. Place Allen's code into a general module. Your Click event would call the GoHyperlink function in VBA procedure or even directly in the Click property (=GoHyperlink([path field name]).
    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
    Pbear88 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    26
    Thanks June7,

    I tried both methods and it still didn't launch the hyperlink. Actually it didn't do anything. No errors or anything. Your suggestions were pretty straight forward, so I'm not sure where I went wrong. Here is the code I inserted into the OnClick property of the text box field:

    Private Sub MyhyperlinkField_Click()

    Application.FollowHyperlink ([MyhyperlinkField])

    End Sub

  4. #4
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You can't reference a form control without telling Access the name of the parent object (the name of the form it's on).
    Try (Me.[MyhyperlinkField])
    When the referenced control IS on the same form as the running code, you can use the short form on the object syntax by using the keyword Me.
    When the referenced control is NOT on the form that the code is running from, the complete object reference is required:
    Forms!frmMyFormName.myControlName ,where obviously you provide the correct object names - not the pseudo names I've used.

    If you are sure that simply clicking in the field is sufficient (i.e. you will never want to edit the value shown) then np. Otherwise, I usually use the double click event to avoid firing such code when the user clicks into the control.
    Last edited by Micron; 08-14-2017 at 06:04 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Pbear88 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    26
    I figured it out. It didn't like that I was trying to use the FollowHyperlink with the same field that I was referring to in the code. So, I just made a button that would launch the code:

    FollowHyperlink "file:///" & Me.MyhyperlinkField

    Thanks

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

Similar Threads

  1. Convert Hyperlink field to Text
    By izzo248 in forum Access
    Replies: 3
    Last Post: 08-24-2015, 08:44 PM
  2. Dafault hyperlink text
    By ortizgabe in forum Access
    Replies: 3
    Last Post: 07-08-2015, 09:29 AM
  3. Default Hyperlink Text
    By mrmims in forum Forms
    Replies: 4
    Last Post: 07-07-2015, 04:17 PM
  4. importing hyperlink with text
    By Mak_kap in forum Import/Export Data
    Replies: 9
    Last Post: 02-10-2011, 07:38 PM
  5. have hyperlink use own name/text
    By airhud86 in forum Access
    Replies: 1
    Last Post: 12-16-2009, 09:35 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