Webbrowser control problem opening new window

owensbri

Registered User.
Local time
, 18:05
Joined
May 5, 2012
Messages
28
I am experiencing an unusual (to me) problem using an embedded Web Browser control on a form. I have stripped the entire database down to an empty table and a single form with a web browser control. The web browser loads the specified internet site, which contains a search form. After providing some search criteria and submitting this form, it opens the results in the same window. Up to this point, everything functions properly. When you click a link on the results page, the site automatically loads the target in a new window (in order to preserve your results page in the first window.) This step prompts an Internet Explorer Browser window to open and attempt to load the target page. At this point, I receive an obscure error message from the target page's server instead of the expected page.

I believe the issue has something to do with Access not properly passing the 'new window' target link to Internet Explorer. I am wondering why, if a new window is needed, it isn't handled within Access, instead of invoking Internet Explorer to display it.

If anyone is interested, here is the address I am using as the control source for the Web Browser control. If you wish to recreate what I am describing, you can try to follow my steps in order to see the error.

http://www.dcjs.virginia.gov/ps/directory/rocs/Search.aspx?facility=N

On the right hand side of the form, search the name John Smith. On the results page, click on any of the links to a certification details page and you will see the error come up with Internet Explorer.

Thanks in advance for any help.
 
By me, no errors. :-)
 
I'm not sure what your reply meant. Are you saying you followed my steps are did not experience any problems?
 
Probably, I also tried in Firefox and IE 8 and nothing extraordinary happened.
 
You were able to make Access launch Firefox from within the database?

To be clear, the problem is occurring from within an Access 2010 database. I am embedding a Web Browser control in a form, and assigning the URL to its control. When following the search & results steps from within the database, the error occurs. I do not have any problems using the URL with Chrome, Firefox, or Internet Explorer outside of Access. Here are the exact steps I am taking that reproduces the problem.

1. Open a new Database
2. Create a blank form
3. Create a Web Browser control in the Form. When the Wizard pops up, provide the following URL as the Control Source:
http://www.dcjs.virginia.gov/ps/directory/rocs/Search.aspx?facility=N
4. Save the form as whatever name you wish
5. Open the form
6. In the search criteria of the web page on the right hand side, search for the name John Smith and then run the search
7. When the page changes to display a list of "John Smith" links, click on any of them to attempt to view the target page
8. Access attempts to open the target in a new Internet Explorer window. In this new window that pops up, I am receiving a Server Error message.

If you follow those steps and do not get the same result I do, then I am in even bigger trouble than I thought.
 
Been kinda quiet for a few days. Hoping someone has an idea what is going on, and/or how to fix it.

Thanks in advance.
 
Tell us more about your set up - database, server etc. You are working with a form available to internet users.

When I access the form and do a search, I get no errors. I simply put a D in lastName and got a list as expected.

I'm using Firefox on Vista Home on this laptop.
 
Thanks for looking at it.

For me, the issue is independant of any particular hardware being used. I experience the exact same results at work and at home. At work I am using a WinXP Pro 32-bit desktop with IE8 as the default browser, and Access 2010. At home I am using a Win7 Pro 64-bit Laptop with Chrome rev 25 as the default browser, and Access 2010.

You mentioned searching "D" for the last name and successfully getting a list of people whose last name starts with "D." I too have no trouble at this step. It is the following step that gives me the error. On the list of names if you click on one to see the details of that person, the Web Browser control inside Access then launches an new instance of IE to display the details. In that new window is where I see a Server Error.

The URL link is to a public web site that I have no affiliation to. I am not trying to trouble shoot a problem with the web site, per se. I am putting together a project at work that will have this public web site intigrated in it, so I need to understand and resolve what is causing this result, or come up with a totaly different way of doing it.

Again, thanks for your time in looking at this!
 
Other than the error, what do you want to happen? You should not be getting the error. I have a feeling that the webbrowser control and webbrowser itself are not communicating correctly. Given that this control (wrapper for com) is very very old it is possible.

One thing you could do is there is a newwindow event in the webbrowser control, you can "capture" the new window before it opens and put it also into a form and of course cancel the new window opening IE.
 
PS if you make up a little access example and post it, I will test it for you. Access 2007 would be best for me.
 
For this specific project, the page that opens with the error would be the final displayed product. So if there is a method to capture it within Access and display it correctly, that would work. Beyond that, for curiosity's sake, i'd feel more comfortable understanding the cause of the error.

You mentioned something called a "newwindow event" in the Web Browser control? I don't see that as an available event for the control. How would I use that event? (preferrably using VBA)
 
Beyond that, for curiosity's sake, i'd feel more comfortable understanding the cause of the error.

If you make me an example where you get an error I will take a look at it.

You mentioned something called a "newwindow event" in the Web Browser control? I don't see that as an available event for the control. How would I use that event? (preferrably using VBA)

Something like this
Code:
Private Sub wb_NewWindow2(ppDisp As Object, Cancel As Boolean)
On Error GoTo Err_wb_NewWindow2

'your new form
Dim frmWB As Form


'get the new form ready but keep it hidden
DoCmd.OpenForm "yourFormName", , , , , acHidden

'get me an object
Set frmWB = Forms("yourFormName")

'no idea why I have to do this
frmWB.newWB.RegisterAsBrowser = True

'set the info that current have to a new window
Set ppDisp = frmWB.newWB.Object

'make the form visible
frmWB.Visible = True

Exit_wb_NewWindow2:
    Exit Sub

Err_wb_NewWindow2:
    MsgBox Err.Description
    Resume Exit_wb_NewWindow2
End Sub
 
I tried the code, with several different variations, and had no success. I am attaching a sample DB as requested.

Open the form, and type in a name on the right side to search. The next page will contain a list of names that match the search criteria. Click on any of the names to attempt to load the next page. This should create a new window, and either show you the details of the person's certifications or a Runtime Error / Server Error message.

On a side note, I noticed that when I created this sample database the entire process worked correctly. When I closed the database and re-opened it, the process no longer worked.

This is really confusing the hell out of me...
 

Attachments

If you put in the link generated, should it not be displayed in the form / window?
Link generated:
"http://www.dcjs.virginia.gov/ps/directory/rocs/Details.aspx?agency_id=1&license_id=88863&"
But then you get: "There is an error with your input. * Wrong number of parameters specified"
Original link
"http://www.dcjs.virginia.gov/ps/directory/rocs/Search.aspx?facility=N"
I do not know if the above is a hint for you or not.
 
I discovered that same thing as well. Strangely, if you were to change the URL in the Web Browser control source to the final linked page, you get a different error. This is the whole crux of the issue. It seems as though clicking through the links on the list of names within Access somehow alters the path so it fails.

I'm just glad someone else finally sees the issue.
 
If you take the generated link and add "amp;" at each parameter, then the information gets showed, see attached picture:
I don't know how you generate the link in you code, but I would take a closer look at that part.

="http://www.dcjs.virginia.gov/ps/directory/rocs/Details.aspx?agency_id=1&license_id=88863&"
 

Attachments

  • IsShowed.jpg
    IsShowed.jpg
    84.4 KB · Views: 189
Last edited:
The web site is a public web site, not something I created. I'm just simply accessing it as a feature of a database i'm working on.
 
Hi mate,

So the example you gave us/me I could not get to open. I dont know what format it was but my access 2007 complained so here is mine attached below.

1. I dont know much about web sites, but my guess is that when you do a search there are either tokens or .js files kept in the temp folder or somewhere, which are then needed when you click on someones name. I also think (guess) that these are saved in different places by the webbrowser control and IE. The reason why it works sometimes and not others is because sometimes you have had IE already open and done a search there.

To test this open the search page in IE. Then open the same page in your access DB and do the search. When you click on a name and open the page in a new IE tab it works.

2. If you look down the bottom right of the web page in IE you will see that the page is done with errors.
Webpage error details

Message: Syntax error
Line: 7
Char: 1
Code: 0
URI: http://www.dcjs.virginia.gov/ps/directory/rocs/javascript/functions.js
This error is suppressed in IE but not in the webbroswer control. in the VBA com version of the webbrowser control all you can do is set the silent property to TRUE. In big programing school .NET you have other options.

So you have to make a choice you can do it all in IE or you can do it all in the webbrowser control. My example does this all in the webbrowser control.

If the names you are searching for are in you DB then you could get the user to choose the name and then click on a button in access. Then you could open IE and inject the name into the right fields and then click on the search button. This would mean that the first interaction the user would have to make is with the choice of name. Also you can follow the user as they do this :cool: in the navigation complete you can tell once they have clicked on a name, then you could read the information on the page and bring it back to your database, which is I guess what you want to do.

Have fun.

edit. in my example, open Form2 and wait. Do a search and click on the name. Form 3 will then automatically open without error with your page.
 

Attachments

I just had a look at the HTML behind the search page, it would be very easy I think to fully control this page. For example the text box for first name
Code:
<td class="label" rowspan="1" colspan="1"><span id="lab_first_name">First/Mid Name:</span></td> 				<td class="textbox" rowspan="1" colspan="1"><input name="t_web_lookup__first_name" type="text" id="t_web_lookup__first_name" value="" tabindex="20" maxlength="50" /></td>
It has an ID which is unique so you can very simply get this and then add your text to it. So to the search button it also has an ID. If this is on all the elements you need then you can get them very simply.

Code:
<td class="button" rowspan="1" colspan="1"><input type="submit" name="sch_button" value="Search" id="sch_button" tabindex="80" maxlength="9" class="button" /></td>
 
Darbid, the functionality of your example DB is what I was looking for. I'll mess around with it when I get some free time this afternoon. Thanks a bunch!
 

Users who are viewing this thread

Back
Top Bottom