Trigger Hyperlink From an Adjacent Label

How can I trigger the hyperlink stored in a hyperlink field on a form,
by clicking on an adjacent (but unrelated) Label.

The Labels are called LabelWEB1, LabelWEB2 etc
The Fields and Control Sources are called WEB_1, WEB_2 etc

Design View
LVL 25
EirmanChief Operations ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PatHartmanCommented:
In the double-click event of the control, use the FollowHyperlink method and reference the control or field where the hyperlink is located.
EirmanChief Operations ManagerAuthor Commented:
Pat, I tried this (and several variations) with no success ....

Private Sub LabelWEB1_Click()
    Application.FollowHyperlink Forms!Contacts!WEB_1
End Sub

Open in new window

(Also, how do I get rid of the Hyperlink security warning)
EirmanChief Operations ManagerAuthor Commented:
Perhaps GoHyperlink() would be better  ?
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

PatHartmanCommented:
Eirman,
What is GoHyperlink()?  It is not an Access function.

The security warnings come from Windows and I am not exactly sure how to get rid of them.  They don't ever happen on my PC but I have had users get the warning but the desktop support people were able to resolve the problem.  I can't remember how they did it.
EirmanChief Operations ManagerAuthor Commented:
What is GoHyperlink()?  It is not an Access function
Correct Pat - Its actually an Allen Browne function.

I'd appreciate it if you could correct my use of FollowHyperlink above.

This sort of works, but even after allowing all hyperlinks in the Access Trust Centre
there are still security issues-  e.g. must be https + must end with /
Private Sub LabelWEB1_Click()
Dim HypString As String
HypString = Me.WEB_1
Application.FollowHyperlink HypString, , True

'    GoHyperlink (Me.WEB_1)
End Sub

Open in new window

Similar results with GoHyperlink()
PatHartmanCommented:
EirmanChief Operations ManagerAuthor Commented:
Thanks for help you Pat. This works 100% .......
Private Sub LabelWEB1_Click()
    WEB_1.SetFocus
    SendKeys "{ENTER}"
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EirmanChief Operations ManagerAuthor Commented:
This code variation fixes the NUMBER LOCK turning off problem.

Private Sub LabelWEB1_Click()
    WEB_1.SetFocus
    SendKeys "{NUMLOCK}"
    SendKeys "{ENTER}", True
End Sub
PatHartmanCommented:
Are you saying that send keys executes the FollowHyperlink command without error whereas referencing the field that contains the Hyperlink causes the security error?  Because sendkeys is not recommended at all.
EirmanChief Operations ManagerAuthor Commented:
When I click on the hyperlink itself, it always works - 100% ; this has always been the case.
(There was never ever a security issue, just clicking on the text box).

The sendkeys solution merely simulates that by clicking elsewhere (e.g. a button or in my case a label)
which was what I wanted to do, as outlined in the original question.

FollowHyperlink referencing a hyperlink type textbox, caused all the security problems.
Sendkeys may be coarse/inelegant, but it works!
PatHartmanCommented:
I guess that's the difference.  I NEVER use the Hyperlink data type because it is not supported in SQL Server.  It is a Jet/ACE only data type and I always avoid those because they get in the way of upsizing and there is ALWAYS an alternate solution.
EirmanChief Operations ManagerAuthor Commented:
It is a Jet/ACE only data type
I didn't know that.
Thanks for your help.
PatHartmanCommented:
You're welcome.

You should take from this follow on conversation the information that the field does not need to be defined as a Hyperlink data type as long as you are willing to write the single line of code to perform the FollowHyperlink command in the double-click event of the control.
EirmanChief Operations ManagerAuthor Commented:
I'll try that - Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.