dbTalk Databases Forums  

A2010 Web browser control questions

comp.databases.ms-access comp.databases.ms-access


Discuss A2010 Web browser control questions in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Salad
 
Posts: n/a

Default A2010 Web browser control questions - 01-15-2011 , 12:59 PM






I don't have a handle on A2010's web browser control. Obviously I'm
missing something.

1) If I set the control source to http:/www.google.com it presents
googles window just fine.

If I set the control source to Null, it presents a form that says
"Address not valid".

Must a control source always be set for a web browser control source.


2) I set the control source as http://www.google.com. I place a command
button on the form. I have the following code for the command button.
Private Sub Command1_Click()
Me.WebBrowser0.ControlSource = "http://www.youtube.com"
msgbox Me.WebBrowser0.ControlSource
End Sub

It shows the control source as "http://www.youtube.com". It does not
move to youtube.

Using some code found on the web I also tried
Me.WebBrowser0.Object.Navigate = "http://www.youtube.com"

That presents the runtime error 438 "Object doesn't support this
property or method.

Is there a way to navigate to another page via code?

3) I thought it might be neat to see the current URL value. So I have
the following code.
Private Sub WebBrowser0_DocumentComplete(ByVal pDisp As Object, _
URL As Variant)
MsgBox "Doc Complete " & vbNewLine & URL
End Sub

When I first open the form, the URL is "about:Blank" I enter "YouTube"
into Googles Search Bar. I get a long google search string to find
"YouTube" and land on that search page. I then hit the link "Music" on
the new page. I get 3 DocCompletes msgboxes; "about:Blank",
"http://www.youtube/music", and "javascript:''"

Is there a method one can get the current URL contained in the web
browser control?

Reply With Quote
  #2  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: A2010 Web browser control questions - 01-15-2011 , 07:04 PM






?"Salad" wrote in message
news:Lv-dnTG6T6MIc6zQnZ2dnUVZ_sSdnZ2d (AT) earthlink (DOT) com...

Quote:
Must a control source always be set for a web browser control source.
No, but when unbound, it much like setting the control source for most
controls.

So, it does have to be a expression that would be legal to type into a
control source.

So, to navigate, you could use:

Dim s As String

s = "=(""www.google.ca"")"

Me.WebBrowser93.ControlSource = s
Me.WebBrowser93.Visible = True

So, the string s in above evaluates to:

=("www.google.ca")

You can also use a string like:

="www.google.ca"

Note that if the control IS bound, then you can just set the value directly.

eg:

Me.WebBrowser108.value = "www.google.ca"

I also in the above had set the default for the control to be not visible if
you looking to eliminate the not found web page message.

Quote:
2) I set the control source as http://www.google.com. I place a command
button on the form. I have the following code for the command button.

Me.WebBrowser0.ControlSource = "http://www.youtube.com"
As noted, if above will work if you use value WHEN it is about,

However, if unbound, then:

Me.WebBrowser93.ControlSource = "=(""www.youtube.com"")"

Quote:
Is there a way to navigate to another page via code?
I not tried this, but there is the move property. (I quite new to this
control also).

Quote:
3) I thought it might be neat to see the current URL value. So I have
the following code.

Quote:
Is there a method one can get the current URL contained in the web browser
control?
Try:

MsgBox Me.WebBrowser93.LocationURL

So, if you pop open a form in dialog mode, you could have a person perform a
web search. And after they seach a few times and find what they want, then
you can have the user hit ok, and then the calling code that opened that
form as dialog can grab the URL. So they could search for anything, and
then you can then stuff that selected URL into the database column, or do
whatever. This could be web documents, pictures of parts or cars, or
whatever.

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
Pleasenospam_kallal (AT) msn (DOT) com

Reply With Quote
  #3  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: A2010 Web browser control questions - 01-15-2011 , 09:17 PM



?.WebBrowser0.ControlSource = "http://www.youtube.com"

As noted, if above will work if you use value WHEN it is about,

should read:

As noted, if above will work if you use value WHEN it is bound

Reply With Quote
  #4  
Old   
Salad
 
Posts: n/a

Default Re: A2010 Web browser control questions - 01-16-2011 , 11:51 AM



Albert D. Kallal wrote:

Quote:
?"Salad" wrote in message
news:Lv-dnTG6T6MIc6zQnZ2dnUVZ_sSdnZ2d (AT) earthlink (DOT) com...

Must a control source always be set for a web browser control source.


No, but when unbound, it much like setting the control source for most
controls.

So, it does have to be a expression that would be legal to type into a
control source.

So, to navigate, you could use:

Dim s As String

s = "=(""www.google.ca"")"

Me.WebBrowser93.ControlSource = s
Me.WebBrowser93.Visible = True

So, the string s in above evaluates to:

=("www.google.ca")

You can also use a string like:

="www.google.ca"

Note that if the control IS bound, then you can just set the value
directly.

eg:

Me.WebBrowser108.value = "www.google.ca"

I also in the above had set the default for the control to be not
visible if you looking to eliminate the not found web page message.

2) I set the control source as http://www.google.com. I place a
command button on the form. I have the following code for the command
button.


Me.WebBrowser0.ControlSource = "http://www.youtube.com"


As noted, if above will work if you use value WHEN it is about,

However, if unbound, then:

Me.WebBrowser93.ControlSource = "=(""www.youtube.com"")"

Is there a way to navigate to another page via code?


I not tried this, but there is the move property. (I quite new to this
control also).

3) I thought it might be neat to see the current URL value. So I have

the following code.

Is there a method one can get the current URL contained in the web
browser control?


Try:

MsgBox Me.WebBrowser93.LocationURL

So, if you pop open a form in dialog mode, you could have a person
perform a web search. And after they seach a few times and find what
they want, then you can have the user hit ok, and then the calling code
that opened that form as dialog can grab the URL. So they could search
for anything, and then you can then stuff that selected URL into the
database column, or do whatever. This could be web documents, pictures
of parts or cars, or whatever.

My wife has stated that if an elephant were in our room I'd ask "What
elephant are you talking about?" LocationUrl was right there in my face
yet I didn't see it. Thanks for that pointer.

Adding the "=" to the ControlSource string did the trick when assigning
to the control source, even moving to it.

Me.WebBrowser0.Object.Navigate or Me.WebBrowser0.Navigate didn't work.
I'm not sure what .Navigate is used for.

Your comments really helped.

Reply With Quote
  #5  
Old   
David-W-Fenton
 
Posts: n/a

Default Re: A2010 Web browser control questions - 01-16-2011 , 04:19 PM



Salad <salad (AT) oilandvinegar (DOT) com> wrote in
news:QeGdnWwS7smCra7QnZ2dnUVZ_v2dnZ2d (AT) earthlink (DOT) com:

Quote:
Adding the "=" to the ControlSource string did the trick when
assigning to the control source, even moving to it.
I haven't used the A2010 web browser control, but I've used earlier
versions, and it seems to me like you're attempting to do things in
a way that would not have been the correct method in the old web
browser control.

Quote:
Me.WebBrowser0.Object.Navigate or Me.WebBrowser0.Navigate didn't
work. I'm not sure what .Navigate is used for.
I'm too lazy to turn on the PC with A2010, but in the older web
browser control, .Navigate was a method, not a property, so you
don't use an = sign, but just provide an argument for it to navigate
to:

Me!ctlWebBrowser.Navigate "http://google.com"

(that's from an existing app using the pre-A2010 web browser
control, which was not an Access control)

In the old control, I have always used the .Navigate method to load
any page or HTML. I don't know that the old control could be bound
to a field, but I think that if you're using it unbound, you
shouldn't set the ControlSource property at all, but instead just
use the .Navigate method, as with the old control.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.