Previous Page
Next Page

Hack 97. Use a Browser Inside Access

Place the Microsoft web browser on a form to coordinate data and the Web.

Access tables have a hyperlink field type, which stores a URL that, when clicked, opens your computer's browser and displays the site. This is useful, but to view the database information and the web site together is a challenge. You might have to reduce the size of both Access and the browser so that they fit together on your computer screen.

This hack puts the browser right on the Access form. To view the web site at the stored URL, you just load the browser with the URL address, and the web site appears on the form.

Figure 10-5 shows a form in Design mode. The Microsoft Web Browser control (one of the items in the list of More Controls that is available from the button on the toolbox) has been placed on the form.

Figure 10-5. Selecting the Microsoft Web Browser control


Figure 10-6 shows the form in View mode.

The browser control displays the web site listed in the current record. This occurs when you click the Display Web Site button, which has this line of code in its Click event:

   Me.WebBrowser1.Navigate URL:=Me.website

The web browser control has the Navigate method, and it navigates to the supplied URL. In this example, the URL comes from the website field on the form, from the current record. Of course, you can feed a URL to the web browser control in other ways. This is just one example.

Figure 10-6. Viewing a web site on the form


Just like any control, you can place multiple web browser controls on a form. Figure 10-7 shows such an arrangement.

Figure 10-7. Multiple browsers on a form


This might seem excessive, but actually, you might have a good reason for using multiple browsers. For example, an application that integrates with current events can use this. Financial applications could keep tabs on different securities markets. The browser controls could even be displaying the output of webcams.

    Previous Page
    Next Page