Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need a button to open URL in browser. 2

Status
Not open for further replies.

WozFromOz

Programmer
Mar 31, 2001
16
AU
Probably a simple question, but how do I make a button open a URL held in a text field in the computers default browser?

I don't want the link in a hypertext field as the database will be used with ASP and so I want the URL in plain text. However I do want to be able to open the link in a browser for visual verification. I figure a button with code whould be able to pick up the text and send it to the browser but I can't figure out how.

Thanks
WozFromOz
 
Command buttons have a hyperlink address property. The code is as such...

ButtonName.HyperlinkAddress = "
You could replace the string with a variable that gets your links text from whereever it is.

Hope I understanding you correctly.

B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
Thanks Lonnie, I think you do understand me but I am still not sure how to do this.

How do I make a button to dynamically pick up a URL from a field and open this in an external browser?

Thanks again
WozFromOz
 
If the hyperlink address is in an actual field on your form, then I assume you are getting it from a table. In the table set the datatype for the field that contains the link to HyperLink. Now the string should appear in the field looking just like a hyperlink. At this point you have two choices. You can have the user click directly on the field itself or you may still use your command button with the Hyperlink.Follow method like so...

Private Sub YourButton_Click()
YourField.Hyperlink.Follow
End Sub

YourButton would be the actual name of your command button.
YourField would be the actual field name of the field on the form.

Let me know how this works B-)

ljprodev@yahoo.com
ProDev
MS Access Applications
 
Hi Lonnie,

thanks for the reply, just getting back to this problem now.

What I am wanting to so though is similar to what you have siggested but getting the hyperlink from a pure text field rather than a hypertext field. The reason is that I need to query the database via ASP pages as well and so need to keep the URL clean.

So I still havn't been able to get this working. Any more ideas?

Onya
WozFromOz
 
Sorry,

Keep the field in your table that holds the links as text. On your form put a field that has the text for the link. I will call it txtLink. Now put a command button on the form. I will call it cmdGo. In the Click event of the button set the hyperlink property to the text in txtLink like so...

Private Sub cmdGo_Click()
cmdGo.HyperlinkAddress = txtLink
End Sub

Hope this is close to what you want. B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
Thanks Lonnie, got that happening now.

However, just to be finnecky, each click of the button opens a new browser. Is there some way to have all clicks open in only one browser window? Like the target option in a html hyperlink? IE., if I move to the next record and click on the URL button I want it to load in the same window as the previous record without loading a complete new browser window. Otherwise my task bar will fill up in no time at all.

Again, many thanks
Onya
WozFromOz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top