ACC: How to Explore an Internet Site from MS Access 2.0 or 95

ID: Q160122

The information in this article applies to:

SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

This article describes a technique for using the Shell() function in Microsoft Access 2.0 or 7.0 to start Microsoft Internet Explorer by double- clicking a Web address field on a form.

In Microsoft Access 97, this functionality is built-in. The label, command button, and image form controls contain Hyperlink properties that allow you to jump to a Web address just by clicking the control.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access for Windows 95" manual.

NOTE: Visual Basic for Applications is called Access Basic in Microsoft Access version 2.0. For more information about Access Basic, please refer to the "Building Applications" manual.

MORE INFORMATION

This technique enables you to run Microsoft Internet Explorer without using special ActiveX controls or Windows application programming interface (API) procedures in your application. It passes the Uniform Resource Locator (URL) to Microsoft Internet Explorer as a command-line argument. For example, "C:\Program Files\Internet Explorer\Iexplore.exe www.microsoft.com." You can modify this example to work with any Web browser software that accepts a URL as a command-line argument.

To start Microsoft Internet Explorer using this technique, you must know the full path to the file Iexplore.exe, or the file's path must be set in your computer's PATH variable.

The following example shows you how to start Microsoft Internet Explorer by double-clicking a field on a form.

1. Open the sample database Northwind.mdb (or NWIND.MDB in version 2.0).

2. Create the following new table:

      Table: WebTable
      ----------------------------------------------------
      Field Name: ID
         Data Type: AutoNumber (or Counter in version 2.0)
      Field Name: Site
         Data Type: Text
         Field Size: 255
      Field Name: SiteDesc
         Date Type: Text
         Field Size: 255

      Table Properties: WebTable
      --------------------------
      PrimaryKey: ID

3. Open the table in Datasheet view and enter the following records:

      Site                                SiteDesc
      -----------------------------------------------------------------
      www.microsoft.com                   Microsoft Home Page
      www.microsoft.com/MSAccessSupport   Microsoft Access Support Page

4. Create the following new form based on the WebTable table:

      Form: WebForm
      ---------------------------------
      RecordSource: WebTable
      Caption: Web Form

      Text Box:
         Name: txtID
         ControlSource: ID
      Text Box:
         Name: txtSite
         ControlSource: Site
         OnDblClick: [Event Procedure]
      Text Box: txtSiteDesc
         Name: txtSiteDesc
         ControlSource: SiteDesc

5. Type the following event procedure in the OnDblClick property of the
   txtSite text box control:

      Private Sub txtSite_DblClick (Cancel As Integer)
      Dim PATH As String, CMD As String, X As Integer
      ' Type the path where Iexplore.exe is located on your computer.
      PATH = "C:\Program Files\Internet Explorer\"
      ' Default command line for Microsoft Internet Explorer.
      CMD = Chr(34) & PATH & "Iexplore.exe" & Chr(34) & " " & Me![txtSite]
      ' Start Internet Explorer.
      X = Shell(CMD, 1)
      End Sub

6. Save the WebForm form and open it in Form view. Double-click the txtSite
   field on the record representing Microsoft Home Page. Note that Internet
   Explorer opens and displays the Microsoft Home Page.

7. Move to the next record representing Microsoft Access Support Page and
   double-click the txtSite field. Note that a second instance of Internet
   Explorer opens and displays the Microsoft Access Support page.

REFERENCES

For more information about using the Shell() function, search the Help Index for "Shell function."

For information about opening files or hyperlinks using Windows API calls, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q148632
   TITLE     : ACC: Start Files or Hyperlinks with Windows API
               ShellExecute()
Keywords          : kbusage FmsHowto IntpWeb 
Version           : 2.0 7.0
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto

Last Reviewed: August 30, 1997