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

jms3257

Member
Local time
Today, 15:18
Joined
Apr 18, 2020
Messages
33
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.
Unfortunately that won't work. in the test form with the 3 fields it might. but for the website form each line will be a different line and will vary for each entry.
 

jms3257

Member
Local time
Today, 15:18
Joined
Apr 18, 2020
Messages
33
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.

We have a winner. This works on my "frmWeb_Sub" but not on "frmTest" I'm guessing that is because web-sub is using a URL and Test is using hyperlinks. This will work because I haven't commented to using one or the other. Recently I posted the question as to use hyperlink's or URL's and most everyone responded with URL's.

Will this work with using an email address or will I need to make a change?

Thank You everyone for responding with help in this matter!
 

Micron

AWF VIP
Local time
Today, 17:18
Joined
Oct 20, 2018
Messages
3,478
It was in the Recordsource .....
You and I are looking at different forms, I guess. In the db I downloaded, the Go button didn't work on subform on frmSchool. That subform is based on table 'tblwebsite' and it has no field named [location] in it.

So while composing this I see that there is an update that what I suggested works? Yes it seems it was suggested earlier (except I left off .Value as it's not required) but it follows what was suggested in post 2. As for referring to a recordsource field when that field isn't on the form, I don't know if you can do so when it's bound to a table. I've read where you can do it when bound to a query but will have to play with the other.

As for email, not sure what you mean. You don't "follow" email addresses, no? That code will not work.
 

jms3257

Member
Local time
Today, 15:18
Joined
Apr 18, 2020
Messages
33
You and I are looking at different forms, I guess. In the db I downloaded, the Go button didn't work on subform on frmSchool. That subform is based on table 'tblwebsite' and it has no field named [location] in it.

So while composing this I see that there is an update that what I suggested works? Yes it seems it was suggested earlier (except I left off .Value as it's not required) but it follows what was suggested in post 2. As for referring to a recordsource field when that field isn't on the form, I don't know if you can do so when it's bound to a table. I've read where you can do it when bound to a query but will have to play with the other.

As for email, not sure what you mean. You don't "follow" email addresses, no? That code will not work.

What was going on was I first tried doing this on the subform linking to tblwebsite. Couldn't get it to work so created the test form, but made the mistake of using existing data that was hyperlink where the subform was URL. The subform is what I was trying to get setup, Test Form is just that and has been deleted. So again Thank You.
 

jms3257

Member
Local time
Today, 15:18
Joined
Apr 18, 2020
Messages
33
As for email, not sure what you mean. You don't "follow" email addresses, no? That code will not work.

The email issue is something else. I have another table for coaches and Athletic Directors that I will need to link there email address to a button. I will deal with latter. I just hope I can learn more by then. I need to spend some time learning more of the coding end of this.
 

Micron

AWF VIP
Local time
Today, 17:18
Joined
Oct 20, 2018
Messages
3,478
Not sure if you overlooked the fact that what you quoted wasn't directed to you, but the person I was quoting.

While fumbling through your db I see that you've aliased a lot of fields. For me, this is one of those things I learned to not do long ago because of issues that arose. Problem is, when I don't do something for a long time, I sometimes forget why it's not a good thing. Your code doesn't work because
a) you've captioned [Location] as Google Map: or
b) you've used the same alias in 2 or more fields or
c) both.
I removed the alias from Location field and your test form works using [Location]. I thought it should because recordsource fields are supposed to be part of the form collection even when there are no bound fields (not true for reports). Then I wanted to see if it was because of the alias alone or because of the duplication so I tried to put the alias back on Location and remove it from anywhere else I found it. Now the field name has a caption (or so it seems) named Map and no matter what I do to that table I can't get rid of it. I also tried a c/r on the db but it didn't remove the name Map. To test any further I think I'd have to download the db again, but I think I will leave it at that. If you want to know if your prior code will work with a caption on Location AND it is the only instance of that caption, try removing it from any other fields where it might be and see if your code accepts [Location] when that field has the caption Google Map:.

In closing, I don't recall anyone posting that special characters in an alias was a bad thing, just in object names. However, I think we could find posts where developers have said don't use captions either and I subscribe to the latter. I don't see how they are useful since no one should be working directly in tables anyway, only in forms, and form controls have labels that you can put pretty much any caption that provides intuitive information about what the field is for.
 

Users who are viewing this thread

Top Bottom