Avatar of Eirman
Eirman
Flag for Ireland asked on

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
Microsoft Access

Avatar of undefined
Last Comment
Eirman

8/22/2022 - Mon
PatHartman

In the double-click event of the control, use the FollowHyperlink method and reference the control or field where the hyperlink is located.
Eirman

ASKER
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)
Eirman

ASKER
Perhaps GoHyperlink() would be better  ?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
PatHartman

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.
Eirman

ASKER
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()
PatHartman

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Eirman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Eirman

ASKER
This code variation fixes the NUMBER LOCK turning off problem.

Private Sub LabelWEB1_Click()
    WEB_1.SetFocus
    SendKeys "{NUMLOCK}"
    SendKeys "{ENTER}", True
End Sub
PatHartman

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.
Eirman

ASKER
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!
Your help has saved me hundreds of hours of internet surfing.
fblack61
PatHartman

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.
Eirman

ASKER
It is a Jet/ACE only data type
I didn't know that.
Thanks for your help.
PatHartman

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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Eirman

ASKER
I'll try that - Thanks