This month, Doug gets some questions that send him back to an earlier topic: linking your Access application into data on the Internet.
How can I get information from the Internet into my app? Back in November 2003, I wrote about how to use the XMLHTTP object to get information from a Web site.
However, after getting more information from the reader who posed the original question, it turns out that approach isn’t really appropriate in his case. Among other issues, my technique assumed that you know the URL that the information will be coming from. The reader who raised the questions is a librarian who wanted to be able to get information about books from the Library of Congress Online Catalog at www.loc.gov/cgi-bin/zgate. However, he needed to be able to interact with the Web page to ensure that the correct book was found. This would have been rather awkward with the technique I showed.
Fortunately, though, there is a solution, as long as you’re using Access 2000 or newer. If Internet Explorer is installed on your computer, then you should also have a Microsoft Web Browser control available for you to use on your form. To test this out, create a new form and, while you’re in Design mode, select ActiveX Control from the Insert menu.
Now scroll through the list of available controls until you find the entry for Microsoft Web Browser. Select it, click the OK button, and a new control will appear on your form.
As a check that you have the right control, the new control will have a name along the lines of WebBrowser0.
In the code that follows, I’ve renamed the control to ocxWebBrowser.
Using the control is simple: Invoke the Navigate method, passing a URL, and your page appears! In the sample database that accompanies this article, I’ve put a textbox named txtURL on the form, as well as a button named cmdGo that will navigate to the URL contained in the textbox. The complete code for the Click event of the
command button is:
If Len(Me.txtURL) > 0 Then Me.ocxWebBrowser.Navigate Me.txtURL End If
Assuming that I’ve got the URL given above in the textbox, clicking on cmdGo takes me to the Z39.50
Gateway to the Library Of Congress Online Catalog.
Read more in the PDF Surf’s up! Parsing web data