How can I code an on click event to open to a URL, hyperlink, from an Access form button?
How can I code an on click event to open to a URL, hyperlink, from an Access form button?
research ms access Application.FollowHyperlink and use that in your click event.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Thank you, I will
You can open a Web Page by setting the Hyperlink Address Property of a Control with the web page Address: https://www.msaccesstips.com
Open the Form in normal view and click on the Control. The web page will open in default browser.
I ended up using a button I already have on the form and putting this in the on click event:
Private Sub Command0_Click()
Dim ctl As CommandButton
Set ctl = Me!Command0
With ctl
.Visible = True
.HyperlinkAddress = "http://ec2....web address here.com"
.Hyperlink.Follow
End With
End Sub
Works, but is a bit verbose:
- if the button wasn't visible, you couldn't click it, so making it visible is of no value
- since the event applies to the very button you're clicking, Dim'ing a variable and setting it to be that same button is of no value
You probably got that from a form Load event code sample, which means that stuff is required - in that case.
Simpler:
Code:Private Sub Command0_Click() application.followhyperlink "https://Google.com" end sub
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.