Newbie looking for help with button linking to website: (1 Viewer)

jms3257

Member
Local time
Today, 16:15
Joined
Apr 18, 2020
Messages
33
I am looking for a YouTube video on how to set up a button to open either a hyperlink or website. Can find a bunch of videos on adding hyperlinks and buttons but nothing linking one to the other. I have done it once but now cannot figure out how I did it of find the video I watched to do it.

Thank You:
 

Micron

AWF VIP
Local time
Today, 18:15
Joined
Oct 20, 2018
Messages
3,478
on button click
Application.FollowHyperlink urlGoesHere ?
You could read up on it

or use what I posted as a search term and look for videos. I don't have any links to videos, but they should be very easy to find now you know what to search on.
 

deletedT

Guest
Local time
Today, 23:15
Joined
Feb 2, 2019
Messages
1,218
I just added a button and set it's hyperlink to google. And it works. What is exactly the problem?

2020-05-19_9-31-23.jpg
 

jms3257

Member
Local time
Today, 16:15
Joined
Apr 18, 2020
Messages
33
I just added a button and set it's hyperlink to google. And it works. What is exactly the problem?

View attachment 82265
Most likely my stupidity. I am getting a "Run-time error '2465': School Sports Database can't find the field 'I1' referred to in your expression.

Private Sub Command6_Click()
Application.FollowHyperlink [Location]
End Sub

I added what you marked above, I still get the same error, but when I select "end" then google opens. I am trying to open a webpage that is listed in a field. I got it to work on another form within the same DB, but cannot duplicate it.
 

Isaac

Lifelong Learner
Local time
Today, 15:15
Joined
Mar 14, 2017
Messages
8,779
Try assigning your location field to a string variable and then using the variable in place of the location with brackets
 

deletedT

Guest
Local time
Today, 23:15
Joined
Feb 2, 2019
Messages
1,218
Can you copy the mentioned form and a simplified version of its source table to a database and upload it?
 

jms3257

Member
Local time
Today, 16:15
Joined
Apr 18, 2020
Messages
33
Not sure what I did different, but am now able to click button and go to google map for the hyperlink. However I have 2 other websites on 2 different fields, and they also go to the google map, and not the hyperlink that they should go to. I am not seeing where the button is connecting to the field with the hyperlink.
 

jms3257

Member
Local time
Today, 16:15
Joined
Apr 18, 2020
Messages
33
Try assigning your location field to a string variable and then using the variable in place of the location with brackets
I am not real sure I understand what you are saying. [Location] should be listed as something else? I was able to get one link to work but 2 others follow the same link.
 

Micron

AWF VIP
Local time
Today, 18:15
Joined
Oct 20, 2018
Messages
3,478
I was going to say this earlier but it looked like you were getting somewhere.
Time to post your code - it's too far away to see from here. ;)
 

jms3257

Member
Local time
Today, 16:15
Joined
Apr 18, 2020
Messages
33
I need to get this correct because the end result will have 18-20 hyperlinks or URL's for each school and there are 150 schools. I can use either a hyperlink or the URL in a text field. But just getting frustrated, that I cannot make it work. Just wish when I found the YouTube Video I would have bookmarked it.
 

deletedT

Guest
Local time
Today, 23:15
Joined
Feb 2, 2019
Messages
1,218
Does this attach database works for you? select a link and click the button. It's what @Micron suggested in first post

It has a link to this page, to google.com and a famous place 20 min from our home.
 

Attachments

  • Database6.accdb
    444 KB · Views: 102

jms3257

Member
Local time
Today, 16:15
Joined
Apr 18, 2020
Messages
33
I was going to say this earlier but it looked like you were getting somewhere.
Time to post your code - it's too far away to see from here. ;)
Not sure what you mean by post your code, but here is a stripped down copy of my DB. The "frmTest" is what I have been working on. The "frmWeb_Sub" is close to what the end result will look like.

I thank everyone for there help.
 

Attachments

  • School_Sports1.accdb
    2.7 MB · Views: 98

Isaac

Lifelong Learner
Local time
Today, 15:15
Joined
Mar 14, 2017
Messages
8,779
They all appear to be working perfectly in your sample DB. on frmTest.

The URL in Location is a Google maps location. So it is correct in navigating to that.

???
 

jms3257

Member
Local time
Today, 16:15
Joined
Apr 18, 2020
Messages
33
Does this attach database works for you? select a link and click the button. It's what @Micron suggested in first post

It has a link to this page, to google.com and a famous place 20 min from our home.
Thank you for this, I will look at this in the morning. I have been looking at my screen for 12 hours and my eyes are really tired. Maybe my mind will be more clear then too. I haven't spent this much time at the computer sense I retired.
 

Isaac

Lifelong Learner
Local time
Today, 15:15
Joined
Mar 14, 2017
Messages
8,779
jms3257 - Ok I think I see what is happening.

Try referring to the control's value (me.controlname.value), rather than the Recordsource field "Location".
 

deletedT

Guest
Local time
Today, 23:15
Joined
Feb 2, 2019
Messages
1,218
When you use hyperlink in this way you should use it as Hyperlinkpart. You can't use location in vba.

change your code to following for each button.

for map
Application.FollowHyperlink HyperlinkPart(Map, 2)

for Mppage
Application.FollowHyperlink HyperlinkPart(MpPage, 2)

For Website
Application.FollowHyperlink HyperlinkPart(Website, 2)

Edit : I attached a corrected version. take a look.
 

Attachments

  • School_Sports1.accdb
    2.8 MB · Views: 92

Micron

AWF VIP
Local time
Today, 18:15
Joined
Oct 20, 2018
Messages
3,478
They all appear to be working perfectly in your sample DB. on frmTest.
But not on the other forms.
jms, where did you get the idea to use [Location] from? I could find no field or control by that name. Your Go button click on frmSchool will work if you change it to

Application.FollowHyperlink Me.Website

because Website is the name of your form control that contains the url - or at least on the form(s) I looked at. I've never used the hyperlinkpart method so I can't say one way is better than the other.
 

Isaac

Lifelong Learner
Local time
Today, 15:15
Joined
Mar 14, 2017
Messages
8,779
because Website is the name of your form control that contains the url
This is what was already suggested in post #15. I take it as "seconding the motion".
:)
 

jms3257

Member
Local time
Today, 16:15
Joined
Apr 18, 2020
Messages
33
Does this attach database works for you? select a link and click the button. It's what @Micron suggested in first post

It has a link to this page, to google.com and a famous place 20 min from our home.
I looked at this and tried it. changed the "Links=cmbLinks" to "Command6" when I ran it got an error
Run-Time error '438':
Object dosn't support this property or method
 

Users who are viewing this thread

Top Bottom