Displaying proper web site for record

S

Steve

Hi,

I would like to have the proper web site display inside the Web Browser
control on a form when I am navigating through records. The url is in a text
field with the table associated with the form. So far I have only been able
to get the web site to appear by visibly placing the url on the form in a
text and using a on click event as such:

Private Sub Homepage_Click()
WebBrowser2.Navigate (Homepage.Text)
End Sub

Not very elegant but I cannot figure how to get access to do this on its own
when I change records.

Thanks for the help, Steve.
 
J

Jeanette Cunningham

Steve,
try setting your textbox format to hyperlink. (properites dialog | format
tab | Is Hyperlink - towards bottom of list)

If the url is stored in a table in a hyperlink field, you can just click the
url in the textbox if the form and the textbox are bound.

Jeanette Cunningham
 
S

Stuart McCall

Steve said:
Hi,

I would like to have the proper web site display inside the Web Browser
control on a form when I am navigating through records. The url is in a
text field with the table associated with the form. So far I have only
been able to get the web site to appear by visibly placing the url on the
form in a text and using a on click event as such:

Private Sub Homepage_Click()
WebBrowser2.Navigate (Homepage.Text)
End Sub

Not very elegant but I cannot figure how to get access to do this on its
own when I change records.

Thanks for the help, Steve.

So what you want is the browser control to display the web page associated
with a record, without user intervention? If so, simply move your code to
the form's OnCurrent event. The OnCurrent event fires as each fresh record
becomes the "current" record, ie the one that is currently shown.
 
S

Steve

I would like to have the proper web site display inside the Web Browser
control on a form when I am navigating through records. The url is in a
text field with the table associated with the form. So far I have only
been able to get the web site to appear by visibly placing the url on the
form in a text and using a on click event as such:

Private Sub Homepage_Click()
WebBrowser2.Navigate (Homepage.Text)
End Sub

I tried as such with this code:

Private Sub Form_Current()
WebBrowser2.Navigate (Homepage.Text)
End Sub

But receive the following error message:

"You can't reference a property or method for a control unless the
control has the focus."

I would prefer to not even have the URL showing on the form.

Thanks, Steve
 
S

Stuart McCall

Steve said:
I tried as such with this code:

Private Sub Form_Current()
WebBrowser2.Navigate (Homepage.Text)
End Sub

But receive the following error message:

"You can't reference a property or method for a control unless the
control has the focus."

I would prefer to not even have the URL showing on the form.

Thanks, Steve

Ah, sorry. I missed that last time. The reason you're getting that error is
because you're referring to the Homepage control's .Text property. Change it
to either Homepage.Value or simply Homepage (because Value is the default
property for controls, so you don't have to include it).

To make the URL hidden, set Homepage.Visible = False.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top