CHAPTER 21

Developing Applications for theInternet and the World Wide Web

This chapter shows you how to use Microsoft Access to develop applications that retrieve, publish, and share information on the Internet or a local area network (LAN). For example, you can create applications that display HTML documents in forms, or you can publish or share information from a database located on a Web server. You can also create hyperlinks that you click to navigate to database objects and other Microsoft Office documents located on a local hard disk or a local area network.

What Is the Internet?

In all likelihood, you are well aware of what the Internet is, and you’ve had a chance to take advantage of its many resources. Even if you have used the Internet, the following overview will help to make sure you understand the terms used to describe it in this chapter.

The Internet is a collection of computer networks that connects millions of computers around the world. The World Wide Web is a client/server technology used to access a vast variety of digital information from the Internet. Using a software client called a Web browser, such as Microsoft Internet Explorer, and a modem or other connection to an Internet Service Provider (ISP), you can easily access text, graphics, sound, and other digital information from practically any computer in the world that is running the appropriate server software on the Internet.

Your Web browser uses a variety of standardized methods for addressing and communicating with Internet servers. These methods are called protocols. The most common protocol is Hypertext Transfer Protocol (HTTP), which was originally created to publish and view linked text documents, but has been extended to display and run a growing variety of graphics, sound, video, and other multimedia content. Other common protocols include File Transfer Protocol (FTP), Gopher, telnet, RealAudio™, as well as protocols used to start other applications such as e-mail and Usenet newsreaders.

To run or display Internet content with a Web browser, you type an address called a Uniform Resource Locator (URL) into its address box. For example, this is the URL for the What’s New page on the Microsoft Access Developer Forum Web site:

http://www.microsoft.com/accessdev/whatsnew.htm

A URL specifies the location of a file on an Internet server. Your Web browser uses a URL to download and open the file, which is most typically a page formatted with Hypertext Markup Language (HTML) tags. HTML tags are codes enclosed in angle brackets that are used by a Web browser to determine the structure and appearance of an HTML document, such as graphic elements and text formatting. For example, the two HTML tags in the following sentence:

Make <B>this text</B> look bold.

Cause the text to display like this when viewed with a Web browser:

Make this text look bold.

To navigate to other pages or multimedia content, a user clicks a hyperlink on a Web page. A hyperlink is colored and underlined text, or a graphic, that activates a URL to download and open another file, such as another Web page or some form of multimedia content, such as a picture or sound file.

You can use HTML tags called anchors to create hyperlinks. An anchor with an HREF attribute jumps to a file outside of the current document. For example, the following anchor creates a hyperlink that jumps to the Microsoft home page:

<A HREF="http://www.microsoft.com">Microsoft Home Page</A>

An anchor with a NAME attribute creates a bookmark at a location within the same document. Other hyperlinks can jump to the bookmark created with thistype of anchor.

HTML was originally a simple system for publishing documents on the Web, but it’s rapidly evolving to include features that you can use to create sophisticated, interactive applications.

Tip You can view an HTML reference that describes the most commonly used HTML tags as well as recent additions supported by Microsoft Internet Explorer and Netscape™ Navigator at http://www.microsoft.com/workshop/author/newhtml/.

If you install Internet server software on servers connected by a local area network (LAN), you can use these same Internet technologies to share data within an organization. Such a system is called an intranet or internal Web. For example, your organization could post human resources information for all employees on a Web page, or a project team could post information about its members and provide hyperlinks to important documentation about the project. All the features in Microsoft Access and Microsoft Office that are designed for the Internet can also be used on an intranet.

Microsoft Office and Microsoft Access Internet Features

In all Microsoft Office 97 applications except Outlook™, you can create hyperlinks in documents or files to display and run standard Internet content. These Microsoft Office applications also extend hyperlink technology so that you can create hyperlinks to navigate between Microsoft Word documents, Microsoft Excel worksheets, Microsoft PowerPoint slides, and Microsoft Access database objects that are stored on a local hard disk or on a LAN. You don’t need Internet connections or servers to use hyperlinks to navigate between Microsoft Office documents or files. You can use both kinds of hyperlinks in the same application.

Microsoft Access provides many ways to create applications that display and run content that is available on the Internet or an intranet. For example, you can use Microsoft Access to publish information from datasheets and reports as Web pages. You can also use Microsoft Access to create files that query a database on a Web server, and then return a Web page to display the results of the query. In addition, you can save a Microsoft Access form as a Web page that emulates many of the features of the form so that users can view, enter, and update information in your database.

The following table summarizes the features available in Microsoft Access that you can use to work with content on the Internet or an intranet.

Feature Uses
Jumping to content on the Internet or an intranet Store hyperlinks in fields with the Hyperlink data type and follow the hyperlinks to display Internet content.
Browse the folders of FTP sites from the Link To File dialog box when inserting or editing hyperlinks.
Bind a text box control on a form to a field with the Hyperlink data type to enter, display, or follow a hyperlink.
Bind a text box control on a report to a field with the Hyperlink data type to create a hyperlink when you save a report as an HTML document or to print the hyperlink address.
Reference a hyperlink from a label, image control, or command button on a form or report.
Use Visual Basic methods and properties to work with hyperlinks. For example, use the FollowHyperlink method to navigate to the address referenced in a hyperlink, and use the AddToFavorites method to add a hyperlink to the Favorites folder.
Jumping to Microsoft Office documents and files Navigate to Microsoft Access objects in the current database or other databases by using hyperlinks from the current Microsoft Access database or from another Microsoft Office application.
Navigate to documents from other Microsoft Office applications by using hyperlinks from Microsoft Access databases.
Use the Back and Forward buttons on the Web toolbar to navigate between followed hyperlinks to database objects and other Microsoft Office documents.
Locate Microsoft Access databases and other Microsoft Office documents with Web Find Fast.
Publishing and sharing data in a database on the Web Save the data from table, query, and form datasheets, or reports as static HTML documents.
Create Internet Database Connector/HTML extension (IDC/HTX) files to query data from a table, query, or form datasheet in a database on an Internet server and display it in a Web page.
Save a Microsoft Access form as an Active Server Page (ASP) that emulates many of the features of the form so that users can view, enter, and update information in a database on an Internet server.
Create an Active Server Page (ASP) to query data from a table, query, or form datasheet in a database on an Internet server and display it in a Web page.
Use the Publish to the Web Wizard to automate the process of publishing and sharing data, store settings from previous publications, and call the Web Publishing Wizard to copy Web files to your Internet server.
Export HTML documents, IDC/HTX files, or Active Server Pages (ASP) by using the OutputTo method or action.
Attach HTML documents, IDC/HTX files, or Active Server Pages (ASP) to e-mail messages by using the SendObject method or action.
Export tables as HTML tables by using the TransferText method or action.
Using the Internet with database replication Synchronize a database replica with a replica or Design Master on an Internet server.
Importing, linking, and exporting data located on the Internet or an intranet Import and link HTML tables and lists by using the Import HTML Wizard and the Link HTML Wizard. When you link HTML tables, the data is read-only.
Import and link any data on an Internet server that is supported by a built-in Microsoft Access driver. When you link data on an Internet server, the data is read-only.
Use the Import and Link dialog boxes to browse FTP sites when you are importing or linking data. You can also use the Import and Link dialog boxes to enter an HTTP address when you are importing or linking data.
Import or link HTML tables by using the TransferText method or action. When you link HTML tables, the data is read-only.
Import or link data by using HTTP and FTP addresses, and export data by using FTP addresses in the following Visual Basic properties, methods, and actions:

Connect propertyCreateTableDef methodOutputTo method and actionTransferDatabase method and actionTransferText method and actionTransferSpreadsheet method and action

Displaying Web pages and other documents in Microsoft Access forms Use the WebBrowser control on your application’s forms to browse Web sites, view Web pages and other documents, and download data located on the Internet. You can use the WebBrowser control to browse sites on the World Wide Web, as well as folders in the local file system and on a network.

The following sections describe each of these features in more detail.

Using Hyperlinks in Microsoft Access Applications

Hyperlinks can jump to two kinds of objects: a Web page or other content on the Internet or an intranet, or to a Microsoft Office document (Microsoft Word document, Microsoft Excel worksheet, Microsoft PowerPoint slide, or Microsoft Access database object) stored on a local hard disk or a LAN.

There are two ways you can use hyperlinks in Microsoft Access applications:

  • Create a field with the Hyperlink data type to store hyperlink addresses in a table, and then bind that field to a text box on a form. Like other bound fields, as the user moves from record to record, the value in the text box changes to display the current record’s hyperlink value. For example, you can use hyperlinks in this way to create an application in which users can jump to Web pages, or to other content on the Internet or an intranet, from a predefined list of addresses. You can also use hyperlinks in this way to create an application that displays and manages Microsoft Office documents.
  • Create a label, image control, or command button on a form that references a specified hyperlink address. In this case, the hyperlink doesn’t change as you move from record to record. For example, you can use hyperlinks in this way to navigate to other database objects within the same database, or to open a Web page on an intranet that contains updated information on how to use your application.

Regardless of how a hyperlink is defined in your application, if the hyperlink jumps to a database object or opens another Microsoft Office document, you can use the Web toolbar to navigate between the hyperlinks you’ve previously followed. For example, in the following illustration, the Products form has a command button with a hyperlink that opens a report. Once you have clicked the hyperlink, you can use the Web toolbar to navigate between other objects you’ve opened with hyperlinks.

Similarly, if you follow a hyperlink from a Microsoft Access form to open a Microsoft Word document, you can click the Back button on the Web toolbar in Microsoft Word to return to the form.

Note   By default, after a user clicks a hyperlink on a form, Microsoft Access continues to display the Web toolbar when the user closes the form. If you want to prevent this, you can use Visual Basic code in the OnClose event of the form to hide the toolbar. To see an example of Visual Basic code that does this, open the Products form in the Northwind sample application in Design view, and then display the event procedure in the OnClose event of the form.

Storing Hyperlinks in Tables

In Microsoft Access 97, a field in a table can store hyperlinks as data. To create a Hyperlink field, add a field in table Design view and set its DataType property to Hyperlink. You can also create a Hyperlink field in table Datasheet view by clicking Hyperlink Column on the Insert menu.

You can follow a hyperlink stored in a table by clicking it in the table, but more typically, the field will be bound to a text box control on a form.

Û To add a text box that is bound to a Hyperlink field to a form

  1. Open the form in Design view.
  2. Make sure the form’s RecordSource property is set to the table that contains the Hyperlink field, or to a query that includes the table.

  3. Click Field List on the toolbar.
  4. Drag the Hyperlink field from the field list to the form.

To see an example of how to use a Hyperlink field, open the Suppliers form in the Northwind sample application. The Home Page text box on the form is bound to the HomePage field in the Suppliers table. Clicking a hyperlink in the text box starts your Web browser and displays the supplier’s home page.

You can also use hyperlinks in Microsoft Access to jump to database objects and other Microsoft Office documents. For example, you could create a document management application that uses a Hyperlink field to store paths to Microsoft Word documents on a network. Users of such an application could add records to track new documents, or click the hyperlink in a previously added record to open the specified document.

The Hyperlink Field Storage Format

A Hyperlink field stores up to three pieces of information: the displaytext, the address, and the subaddress. Each piece is separated by the number sign (#), in the following format:

displaytext#address#subaddress

The following table describes each piece of the Hyperlink field storage format.

Piece Description Required?
displaytext The text the user sees in the Hyperlink field in a table, or in a text box bound to the Hyperlink field. You can set the display text to any text string. For example, you may want the display text to be a descriptive name for the Web site or object specified by the address and subaddress. If you do not specify display text, Microsoft Access displays the value of address instead. No
address A valid URL that points to a page or file on the Internet or an intranet, or the path to a file on a local hard drive or LAN. If you enter a path on a LAN, you can omit a mapped drive letter and use the universal naming convention (UNC) format: \\server\share\path\filename. This prevents the path from becoming invalid if the database is later copied to another computer’s hard drive or into a shared network folder. Yes, unless subaddress points to an object in the current database (.mdb) file.
subaddress The location within a file or document; for example, a database object, such as a form or report. When referring to a database object, the name of the object should be preceded by its type: Table, Query, Form, Report, Macro, or Module. Other possible values for subaddress include a bookmark in a Microsoft Word document, an anchor in an HTML document, a Microsoft PowerPoint slide, or a cell in a Microsoft Excel worksheet. No

Each piece of the Hyperlink field storage format can be up to 2,000 characters. The maximum length of the entire Hyperlink field value is 6,000 characters.

The following table gives examples of valid Hyperlink field values.

Hyperlink field value Jumps to
Cajun Delights#http://www. cajundelights.com/cajun.htm# The Cajun Delights Web page. Only the words “Cajun Delights” are displayed in the field or control.
#http://www.cajundelights.com/cajun.htm# The Cajun Delights Web page. The text “http://www.cajundelights.com” appears in the field or control because no display text is specified.
#http://www.cajundelights. com/cajun.htm#Price The HTML anchor with the NAME attribute Price on the Cajun Delights Web page. The text “http://www.cajundelights.com/ cajun.htm” is displayed in the field or control.
Resume#c:\windows\personal\resume.doc# A Microsoft Word file named Resume.doc located in the \Windows\Personal folder. Only the word “Resume” is displayed in the field or control.
#c:\windows\personal\resume.doc# A Microsoft Word file named Resume.doc located in the \Windows\Personal folder. The text “c:\windows\personal\resume.doc” appears in the field or control because no display text is specified.
#c:\windows\personal\resume. doc#Qualifications The section in the Resume.doc Microsoft Word file marked with the bookmark name Qualifications. The text “c:\windows\ personal\resume.doc” is displayed in the field or control.
#\\databases\samples\northwind.mdb#Form Suppliers The Suppliers form in the Northwind sample application located in the Samples share on the Databases server on a LAN (UNC format path). The text “\\databases\ samples\northwind.mdb” is displayed in the field or control.
Suppliers Form##Form Suppliers The Suppliers form in the current database. The words “Suppliers Form” are displayed in the field or control.
#c:\windows\personal\1996 Sales.ppt#13 Slide 13 in the 1996 Sales Microsoft PowerPoint presentation located in the \Windows\Personal folder. The text “c:\windows\personal\1996 Sales.ppt” is displayed in the field or control.
#c:\windows\personal\budget.xls#Sheet1!A2 The A2 cell in Sheet1 of the Budget.xls file located in the \Windows\Personal folder. The text “c:\windows\personal\budget.xls” is displayed in the field or control.

You can display the stored hyperlink format by pressing F2 when the insertion point is in the Hyperlink field. You can edit the stored hyperlink in this form as long as you enter number signs (#) in the appropriate locations. You can add or edit the displaytext part of a hyperlink field by right-clicking a hyperlink in a table, pointing to Hyperlink on the shortcut menu, and then typing the display text in the Display Text box.

See Also   For more information on the Hyperlink field storage format, search the Help index for “hyperlinks, addresses.”

Entering a URL as a Hyperlink Address

To create a hyperlink that jumps to a Web page or other Internet content, you must enter a valid URL as the hyperlink address. You can enter a URL that points to any Internet file type or resource supported by the browser or to an ActiveX control, such as the WebBrowser control, that will be used to display or run it. You enter most URLs in the following format:

protocol://serveraddress/path

Protocol specifies the Internet protocol used to establish the connection to the server, and is generally followed by a colon and two slash marks. Serveraddress specifies what is usually called the domain name of the Internet server. Path specifies the location and name of the page or file on the Internet server. For example, the URL to the home page of the Microsoft Access Developer Forum is:

http://www.microsoft.com/accessdev/

When you type a URL into a Hyperlink field, Microsoft Access automatically recognizes the following Internet protocols.

Protocol Protocol name Description
http Hypertext Transfer Protocol Jumps to Web pages that contain text, graphics, sound, and other digital information from a Web server on the World Wide Web.
ftp File Transfer Protocol Transfers files between computers on the Internet.
gopher Gopher protocol Displays information on a Gopher server.
wais WAIS protocol Accesses a Wide Area Information Servers database.
file File protocol Opens a file on a local hard drive or LAN.
https Hypertext Transfer Protocol with privacy Establishes an HTTP connection that uses Secure Sockets Layer (SSL) encryption.
Protocol Protocol name Description
mailto MailTo protocol Opens your electronic mail program to send a message to the specified Internet e-mail address. A URL that uses the MailTo protocol has a different format:(mailto:username@domain)
msn Microsoft Network protocol Jumps to a location on The Microsoft Network.
news News protocol Starts a newsreader and opens the specified Usenet newsgroup. A URL that uses the News protocol has a different format:(news:newsgroupname)
nntp Network News Transfer Protocol Performs the same function as News protocol, except two slashes follow the colon (nntp://newsgroupname).
mid Musical Instrument Digital Interface (MIDI) protocol Plays MIDI sequencer files if the user’s computer has a sound card.
cid CompuServe® Dialer (CID) protocol Establishes a point-to-point protocol (PPP) connection with the Internet through CompuServe’s network.
prospero Prospero protocol Opens files on the Prospero distributed file system.
telnet Telnet protocol Starts a telnet terminal emulation program. A terminal emulation program is a command-line interface that you can use to issue commands on a remote computer. For example, by using telnet to connect to a UNIX server, you can issue UNIX commands to perform operations on that server.
rlogin Rlogin protocol Starts an Rlogin terminal emulation program.
tn3270 TN3270 protocol Starts a TN3270 terminal emulation program.
pnm RealAudio protocol Plays RealAudio streaming audio from a RealAudio server. Streaming audio and other streaming media formats establish a connection to the server and start playing immediately without downloading an entire file.
mms Microsoft Media Server (MMS) protocol Plays media such as ActiveMovie™ streaming format files (.asf) from an MMS server.

If you create a field by importing a column of data and all records in the imported data begin with one of these protocols, Microsoft Access automatically sets the data type of the imported field to Hyperlink. Similarly, if you create a new table in Datasheet view, and every entry you make in a field begins with one of these protocols, Microsoft Access sets the data type of the new field to Hyperlink when you save the table.

Creating a Label, Image Control, or Command Button That Follows a Hyperlink

To add a label, image control, or command button that follows a hyperlink to a form, set the HyperlinkAddress and HyperlinkSubAddress properties of the control to point to the content on the Internet or an intranet, or to the Microsoft Office document or Microsoft Access database object you want to jump to.

Note   The HyperlinkAddress and HyperlinkSubAddress property settings correspond to the address and subaddress values entered for a Hyperlink field. For more information on these values, see “The Hyperlink Field Storage Format” earlier in this chapter.

Additionally, to create the hyperlink display text for a label or command button control, you must set the Caption property. No text displays for an image control, so there is no corresponding display text setting.

You can also create a label that follows a hyperlink by opening the form in Design view, and then using the Hyperlink command (Insert menu). However, this method won’t define the display text. To define display text, you must set the label’s Caption property.

See Also   For more information on creating a label, image control, or command button that follows a hyperlink, search the Help index for “hyperlinks, creating.”

Using Visual Basic Methods and Properties to Work with Hyperlinks

Microsoft Access 97 provides a several methods and properties that you can use to work with hyperlinks in Visual Basic code. The following table summarizes these methods and properties.

Method or property name Description
Follow method The Follow method has the same effect as clicking a hyperlink. When you use the Follow method, you don’t need to know the address specified by a control’s HyperlinkAddress or HyperlinkSubAddress property, or by the Hyperlink field that is bound to a text box control. You only need to know the name of the control that contains the hyperlink.
FollowHyperlink method Follows a hyperlink specified in code or passed to the method from an unbound text box. For example, you can prompt a user to type a hyperlink address in a dialog box, and then use the FollowHyperlink method to navigate to that address. You can also use the FollowHyperlink method to specify a hyperlink for controls other than labels, image controls, and command buttons, or text boxes bound to Hyperlink fields.
AddToFavorites method Adds the hyperlink address specified in the referenced control to the Favorites folder.
Hyperlink property Returns a reference to a hyperlink object in code. You can use the Hyperlink property to access the properties and methods of any control that contains a hyperlink.
HyperlinkAddress property Sets or returns the address of a hyperlink for a label, image control, or command button. The HyperlinkAddress property is equivalent to setting or returning the Address property for the control in Visual Basic; for example, object.HyperlinkAddress is equivalent to object.Hyperlink.Address. You can also set the HyperlinkAddress property in the control’s property sheet.
HyperlinkSubAddress property Sets or returns the location within the Microsoft Office document or object specified by the HyperlinkAddress property. When no HyperlinkAddress property is specified, HyperlinkSubAddress specifies a database object in the current database. The HyperlinkSubAddress property is equivalent to setting or returning the SubAddress property for the control in Visual Basic; for example, object.HyperlinkSubAddress is equivalent to object.Hyperlink.SubAddress. You can also set the HyperlinkSubAddress property in the control’s property sheet.
HyperlinkPart function Parses the three parts of a hyperlink stored in a table.

See Also   For more information on these methods and properties, search the Help index for the name of the method or property.

Example of Using the Follow Method

This example uses the Follow method to automatically open the Web page specified in a text box bound to a Hyperlink field on a form. Add the following code to the OnCurrent event of a form. Note that you must use the Hyperlink property to return a reference to the object that contains the hyperlink.

Private Sub Form_Current()
	Dim txt As TextBox

	On Error GoTo Error_Form1

	' Set reference to the txtAddress text box bound to a Hyperlink field.
	Set txt = txtAddress

	' Follow the hyperlink.
	txt.Hyperlink.Follow

Exit_Form1:
	Exit Sub

Error_Form1: 
	MsgBox Err & ": " & Err.Description
	Resume Exit_Form1
End Sub

Example of Using the FollowHyperlink Method

This example uses the FollowHyperlink method to add a hyperlink to a control that doesn’t support the HyperlinkAddress or HyperlinkSubAddress properties. Add the following code to the Click event of an unbound object frame named OLEUnbound1 to start a Web browser and open the specified hyperlink address when you click the image.

Private Sub OLEUnbound1_Click()
	Dim strAddress As String

	On Error GoTo Error_OLEUnbound1

	' Set reference to hyperlink address.
	strAddress = "http://www.microsoft.com"

	' Follow hyperlink address.
	Application.FollowHyperlink strAddress, , True

Exit_OLEUnbound1:
	Exit Sub

Error_OLEUnbound1:
	MsgBox Err & ": " & Err.Description
	Resume Exit_OLEUnbound1
End Sub

Tip Controls that don’t support the HyperlinkAddress or HyperlinkSubAddress properties don’t provide any feedback to the user to indicate that they contain a hyperlink. One way to inform a user that the control contains a hyperlink is to set the control’s ControlTipText property so that a text message appears when users rest the pointer on the control.

Note   You can also use the FollowHyperlink method to prompt a user to enter a hyperlink address and then to follow it. For an example of how to do this, search the Help index for “FollowHyperlink method.”

The HyperlinkPart Function

The HyperlinkPart function returns information about data stored in a Hyperlink field. The syntax for the HyperlinkPart function is:

object.HyperlinkPart(hyperlink As Variant, part As Integer)

The following table describes the arguments of the HyperlinkPart function.

Argument Description
object Optional. The Application object.
hyperlink Required. A Variant that represents the data stored in a Hyperlink field.
part Optional. An intrinsic constant that represents the information you want returned by the HyperlinkPart function.

You can set the part argument to the following constants.

Constant Value Description
acDisplayedValue 0 (Default) The underlined text displayed in a hyperlink.
acDisplayText 1 The displaytext part of a Hyperlink field.
acAddress 2 The address part of a Hyperlink field.
acSubAddress 3 The subaddress part of a Hyperlink field.

Note   If you use the HyperlinkPart function in an SQL statement or a query, the part argument is required and you can’t set it to the constants listed in the preceding table — you must use the value instead.

You use the HyperlinkPart function to return one of three values stored in a Hyperlink field (displaytext, address, or subaddress) or the displayed value. The value returned depends on the setting of the part argument. If you don’t use the part argument, the HyperlinkPart function returns the value Microsoft Access displays for the hyperlink (which corresponds to the acDisplayedValue setting for the part argument).

When a value is provided in the displaytext part of a Hyperlink field, the value displayed by Microsoft Access will be the same as the displaytext setting. When there’s no value in the displaytext part of a Hyperlink field, Microsoft Access displays the value of the address or subaddress part of the Hyperlink field, depending on which value is first present in the field.

The following table shows the values returned by the HyperlinkPart function for data stored in a Hyperlink field.

Hyperlink field data HyperlinkPart function returned values
#http://www.microsoft.com/# acDisplayedValue: http://www.microsoft.com/acDisplayText: No value returned.acAddress: http://www.microsoft.com/acSubAddress: No value returned.
Microsoft#http://www.microsoft.com/# acDisplayedValue: MicrosoftacDisplayText: MicrosoftacAddress: http://www.microsoft.com/acSubAddress: No value returned.
Customers##Form Customers acDisplayedValue: CustomersacDisplayText: CustomersacAddress: No value returned.acSubAddress: Form Customers
##Form Customers acDisplayedValue: Form CustomersacDisplayText: No value returned.acAddress: No value returned.acSubAddress: Form Customers

The following example uses all four of the part argument constants to display information returned by the HyperlinkPart function for each record in a table containing a Hyperlink field. To try this example, paste the DisplayHyperlinkParts procedure into the Declarations section of a module. You can call the DisplayHyperlinkParts procedure from the Debug window, passing to it the name of a table that contains hyperlinks and the name of the field that contains Hyperlink data, as shown in the following example.

DisplayHyperlinkParts "MyHyperlinkTableName", "MyHyperlinkFieldName"

Sub DisplayHyperlinkParts(strTable As String, strField As String)
	Dim dbs As Database, rst As Recordset
	Dim strMsg As String

	Set dbs = CurrentDb
	Set rst = dbs.OpenRecordset(strTable)

	While Not rst.EOF		' For each record in table.
		strMsg = "DisplayValue = " & HyperlinkPart(rst(strField), acDisplayedValue) _
			& vbCrLf & "DisplayText = " & HyperlinkPart(rst(strField), acDisplayText) _
			& vbCrLf & "Address = " & HyperlinkPart(rst(strField), acAddress) _
			& vbCrLf & "SubAddress = " & HyperlinkPart(rst(strField), acSubAddress)
		' Show parts returned by HyperlinkPart function.
		MsgBox strMsg
		rst.MoveNext
	Wend
End Sub

When you use the HyperlinkPart function in a query, the part argument is required. For example, the following SQL statement uses the HyperlinkPart function to return information about data stored as a Hyperlink data type in the URL field of the Links table:

SELECT Links.URL, HyperlinkPart([URL],0)
AS Display, HyperlinkPart([URL],1)
AS Name, HyperlinkPart([URL],2)
AS Addr, HyperlinkPart([URL],3) AS SubAddr
FROM Links;

See Also   For another example of using the HyperlinkPart function, see “Displaying a Document in the WebBrowser Control by Using a Hyperlink Stored in a Table” later in this chapter.

Making Microsoft Access Data Available on the Internet

With Microsoft Access, you can make your data available on the Internet or an intranet by:

  • Saving data as HTML documents.
  • Synchronizing a database replica with a replica or Design Master on an HTTP or FTP server.

Saving Data as HTML Documents

Microsoft Access has four ways to save data from your database as HTML documents:

Save data as static HTML documents You can create static HTML documents from table, query, and form datasheets, and from reports. When you save data as static HTML documents, the resulting pages reflect the state of the data at the time it was saved, like a snapshot. If your data changes, you must save the pages again to share the new data.

Save table, query, and form datasheets as IDC/HTX files You can save your table, query, and form datasheets as Internet Database Connector/HTML extension (IDC/HTX) files that generate HTML documents by querying a copy of your database located on a Web server for current data.

Save forms and datasheets as Active Server Pages You can save your forms as Active Server Pages (ASP) that emulate most of the functionality of your forms and display data from a database located on a Web server. You can also save table, query, and form datasheets as Active Server Pages that display current data from a copy of your database located on a Web server.

Automate the publishing of dynamic and static HTML documents You can use the Publish to the Web Wizard to automate the process of saving multiple objects to any combination of all three file types. In the Publish to the Web Wizard, IDC/HTX files and Active Server Pages (ASP) files are collectively referred to as dynamic Web pages because these file types display current data to users.

The following sections discuss each of these options in more detail.

Saving Data as Static HTML Documents

With Microsoft Access 97, you can save table, query, and form datasheets, and reports as static HTML documents.

Û To save a table, query, or form datasheet, or a report as a static HTML document

  1. In the Database window, click the table, query, form, or report you want to save.
  2. On the File menu, click Save As/Export.
  3. In the Save As dialog box, click To An External File Or Database, and then click OK.
  4. In the Save As Type box, click HTML Documents (*.html; *.htm).
  5. If you want to preserve formatting, select the Save Formatted check box. To automatically open the resulting HTML document in your Web browser, select the Autostart check box.
  6. Specify the file name and location to save the file, and then click Export.
  7. In the HTML Output Options dialog box, if you want Microsoft Access to merge an HTML template with the resulting HTML document, specify that as well, and then click OK.

    See Also   For information on HTML templates, see “Using an HTML Template When You Save Data as HTML Documents” later in this chapter.

You can also save data as static HTML documents by using the Publish to the Web Wizard (available through the Save As HTML command on the File menu), the OutputTo method in code, or the OutputTo action in macros.

See Also   For more information on saving table, query, or form datasheets, and reports as HTML documents, search the Help index for “Saving database objects, saving in Internet/Web formats” or “OutputTo method.”

When saving table, query, and form datasheets, Microsoft Access saves each datasheet to a single HTML file. Microsoft Access saves reports as multiple HTML documents, with one HTML file per printed page. To name each page, Microsoft Access uses the name of the object and appends _Pagenn to the end of each page’s file name after the first page; for example, ProductList.htm, ProductList_Page2.htm, ProductList_Page3.htm, and so on.

Saving Table, Query, and Form Datasheets as Static HTML Documents

When you save a table, query, or form datasheet as an HTML document, the HTML document generated is based on the table or query associated with the datasheet, including any sorting or filtering specified by the current setting of the OrderBy or Filter property of the table or query.

If you select the Save Formatted check box, the HTML document contains an HTML table that reflects as closely as possible the appearance of the datasheet by using the appropriate HTML tags to specify color, font, and alignment. The HTML document follows as closely as possible the page orientation and margins of the datasheet. Whenever you want to use settings that are different from the default orientation and margins for a datasheet, you must first open the datasheet, and then use the Page Setup command (File menu) to change settings before you save the datasheet as an HTML document.

If you select the Save Formatted check box, and a field has a Format or InputMask property setting, those settings are reflected in the data in the HTML document. For example, if a field’s Format property is set to Currency, the data in the HTML document is formatted with a dollar sign, a comma as the thousand separator, and two decimal places; for example, $1,123.45.

Saving Reports as Static HTML Documents

When you save a report as HTML documents, the series of HTML documents generated is based on the report’s underlying table or query, including the current OrderBy or Filter property settings of the table or query.

The HTML documents simulate as closely as possible the appearance of the report by creating the appropriate HTML tags to retain attributes such as color, font, and alignment. The proportions and layout of the actual report follow as closely as possible the page orientation and margins set for the report. To change the page orientation and margins, open the report in Print Preview, and then use the Page Setup command to change settings before you save the report as HTML documents. These settings are saved from session to session for reports, so if you change them once, they will be used the next time you save the form or report as HTML documents.

Navigation Controls When Saving Multiple HTML Documents Per Object

If you specify an HTML template that contains placeholders for navigation controls when you save a report as multiple HTML documents, Microsoft Access creates hyperlinks that the user can use to navigate to the first, previous, next, and last pages in the publication. Where Microsoft Access places the hyperlinks depends on where you locate the placeholders in the HTML template.

See Also   For information on HTML templates and placeholders, see “Using an HTML Template When You Save Data as HTML Documents” later in this chapter.

How Microsoft Access Saves Data Types in HTML Format

When you save data as static HTML documents, Microsoft Access saves values from most data types as strings and formats them as closely as possible to their appearance in the datasheet or report. There are two exceptions:

  • OLE Object fields are not saved.
  • Hyperlink field values are saved as hyperlinks in the HTML document. The hyperlinks use HTML anchor tags with an HREF attribute, as described in the following table.
    If Anchor tag format
    The hyperlink doesn’t include a subaddress <A HREF="address">displaytext</A>
    The hyperlink includes a subaddress <A HREF="address#subaddress">displaytext</A>
    Display text isn’t specified <A HREF="address">address</A>

Microsoft Access determines the displaytext, address, and subaddress values by parsing the value stored in the Hyperlink field.

See Also   For information on the displaytext, address, and subaddress values, see “The Hyperlink Field Storage Format” earlier in this chapter.

Using an HTML Template When You Save Data as HTML Documents

When you save data as HTML documents, you can use an HTML template to give a consistent look to the HTML documents you create. For example, you can include your company’s logo, name, and address in the page’s header, use the background that is used throughout your company, or include standard text in the header or footer of the HTML document.

Note   You can use an HTML template when you save data as static HTML documents, when you save datasheets as IDC/HTX files, when you save a form or datasheet as an Active Server Page, and when you use the Publish to the Web Wizard.

The HTML template can be any HTML document; that is, a text file that includes HTML tags and user-specified text and references. In addition, the HTML template can include placeholders that tell Microsoft Access where to insert certain pieces of data in the HTML documents. When data is saved as HTML documents, the placeholders are replaced with data. The following table describes each of the placeholders that you can use in an HTML template.

Placeholder Description Location
<!--AccessTemplate_Title--> The name of the object being saved Between <TITLE> and </TITLE>
<!--AccessTemplate_Body--> The data or object being saved Between <BODY> and </BODY>
<!--AccessTemplate_FirstPage--> An anchor tag to the first page Between <BODY> and </BODY> or after </BODY>
<!--AccessTemplate_PreviousPage--> An anchor tag to the previous page Between <BODY> and </BODY> or after </BODY>
<!--AccessTemplate_NextPage--> An anchor tag to the next page Between <BODY> and </BODY> or after </BODY>
<!--AccessTemplate_LastPage--> An anchor tag to the last page Between <BODY> and </BODY> or after </BODY>
<!--AccessTemplate_PageNumber--> The current page number Between <BODY> and </BODY> or after </BODY>

When you install Microsoft Access, sample HTML template files and graphics files are installed in the Access subfolder of the Templates folder. The default location of this folder is C:\Program Files\Microsoft Office\Office\Templates\Access.

Saving Table, Query, and Form Datasheets as IDC/HTX Files

With Microsoft Access, you can save a table, query, or form datasheet as Internet Database Connector/HTML extension (IDC/HTX) files that generate HTML documents by querying a copy of your database located on a Web server. In contrast to static HTML documents, which contain the data that was current at the time the HTML document was created, IDC/HTX files generate an HTML page with current data from your database; therefore, the HTML documents that they generate are called dynamic.

Û To save a table, query, or form datasheet as IDC/HTX files

  1. In the Database window, click the table, query, or form you want to save.
  2. On the File menu, click Save As/Export.
  3. In the Save As dialog box, click To An External File Or Database, and then click OK.
  4. In the Save As Type box, click Microsoft IIS 1-2 (*.htx/*.idc).
  5. Specify the file name and location to save the files, and then click Export.
  6. In the HTX/IDC Output Options dialog box, specify:
    • The data source name that will be used for a copy of the current database.
    • A user name and password, if required to open the database.
    • An HTML template, if you want Microsoft Access to merge one with the HTML extension (HTX) file.

    Note   You can specify any of these items later, except the HTML template, by editing the resulting IDC file in a text editor such as Notepad.

  7. Click OK.

You can also save a table, query, or form datasheet as IDC/HTX files by using the Publish to the Web Wizard (available through the Save As HTML command on the File menu), the OutputTo method in code, or the OutputTo action in macros.

See Also   For more information on saving table, query, or form datasheets as IDC/HTX files, search the Help index for “Saving database objects, saving in Internet/Web formats” or “OutputTo method.”

How the Internet Database Connector Works

When you save a table, form, or query datasheet as Internet Connector files, Microsoft Access creates two files: an Internet Database Connector (IDC) file and HTML extension (HTX) file. These files are used to generate a Web page that displays current data from your database.

An IDC file contains the necessary information to connect to a specified Open Database Connectivity (ODBC) data source and to run an SQL statement that queries the database. The information needed to connect to the database includes the data source name, and if user-level security is established for the database, the user name and password required to open the database. For example, if you save the Current Product List query datasheet from the Northwind sample application as IDC/HTX files, Microsoft Access creates the following IDC file:

Datasource:Northwind
Template:Current Product List.htx
SQLStatement:SELECT [Product List].ProductID, [Product List].ProductName
+FROM Products AS [Product List]
+WHERE ((([Product List].Discontinued)=No))
+ORDER BY [Product List].ProductName;

Password:
Username:

An IDC file also contains the name and location of an HTML extension (HTX) file. The HTX file is a template for the HTML document; it contains field merge codes that indicate where the values returned by the SQL statement should be inserted. For example, if you save the Current Product List query datasheet from the Northwind sample application as IDC/HTX files, Microsoft Access creates the following HTX file:

<HTML>
<TITLE>Current Product List</TITLE>
<BODY>
<TABLE BORDER=1 BGCOLOR=#ffffff><FONT FACE="Arial" COLOR=#000000>
<CAPTION><B>Current Product List</B></CAPTION>

<THEAD>
<TR>
<TD><FONT SIZE=2 FACE="Arial" COLOR=#000000>Product ID</FONT></TD>
<TD><FONT SIZE=2 FACE="Arial" COLOR=#000000>Product Name</FONT></TD>
</TR>
</THEAD>
<TBODY>
<%BeginDetail%>
<TR VALIGN=TOP>
<TD ALIGN=RIGHT><FONT SIZE=2 FACE="Arial" COLOR=#000000><%ProductID%><BR></FONT></TD>
<TD><FONT SIZE=2 FACE="Arial" COLOR=#000000><%ProductName%><BR></FONT></TD>
</TR>
<%EndDetail%>
</TBODY>
<TFOOT></TFOOT>
</BODY>
</HTML>

Microsoft Access saves the HTX file to be used with an IDC file with the same name as the IDC file, except with an .htx file name extension rather than an .idc file name extension. After the database information has been merged into the HTML document, it is returned to the Web browser.

If you open Current Product List.idc from a Microsoft Internet Information Server that has an appropriately defined Northwind data source name (DSN), the Web page shown in the following illustration is generated.

Note   You can also reference an HTML template when you create IDC and HTX files. An HTML template contains additional HTML code to enhance the appearance of the resulting pages. If you specify an HTML template, it is merged with the HTX file. For information on the format of an HTML template, see “Using an HTML Template When You Save Data as HTML Documents” earlier in this chapter.

Requirements for Using IDC/HTX Files

To use IDC/HTX files, your database and the IDC/HTX files must reside on a computer running one of the following operating systems and Internet server platforms:

  • Microsoft Windows NT Server version 3.51 or 4.0 running Microsoft Internet Information Server version 1.0, 2.0, or 3.0
  • Microsoft Windows NT Workstation version 4.0 and Microsoft Peer Web Services
  • Microsoft Windows 95 and Microsoft Personal Web Server

Microsoft Internet Information Server, Microsoft Peer Web Services, and Personal Web Server use a component called the Internet Database Connector (Httpodbc.dll) to generate Web pages from IDC/HTX files.

The Internet Database Connector component requires ODBC drivers to access a database. To access a Microsoft Access database, the Microsoft Access Desktop driver (Odbcjt32.dll) must be installed on your Web server. This driver is installed when you install Microsoft Internet Information Server if you select the ODBC Drivers And Administration check box during Setup.

However, the Microsoft Access Desktop driver isn’t installed with Personal Web Server. If Microsoft Access is installed on the computer you are using to run Personal Web Server, and if you selected the driver when you installed Microsoft Access, the driver is already available. If you don’t have Microsoft Access installed on the computer you are using to run Personal Web Server, you must install the Microsoft Access Desktop driver.

Û To install the Microsoft Access Desktop driver

  1. Run the Microsoft Office or Microsoft Access Setup program.
  2. If you are running Setup for the first time, click Custom.

    If you are not running Setup for the first time, click Add/Remove.

  3. Select the Data Access Controls check box, and then click Change Option.

    Important The Microsoft Access check box must also be selected or the driver will not be installed.

  4. Select the Database Drivers check box, and then click Change Option.
  5. Select the Microsoft Access Driver check box, and then click OK.
  6. Click Continue, and follow the instructions in the remaining Setup dialog boxes.

After the Microsoft Access Desktop driver is installed, you must create either a system DSN or a file DSN that specifies the name and connection information for each database you want to use on the server. You then specify that DSN when you generate the IDC/HTX files.

See Also   For information on how to define a system DSN or a file DSN, search the Help index for “ODBC, setting up data sources.” For more information on Microsoft Internet Information Server, see the Microsoft Internet Information Server Web site, located at http://www.microsoft.com/infoserv/iisinfo.htm. For more information on using IDC/HTX files, search the Microsoft Internet Information Server Help index for “database connector.”

Tip You can learn more about applications that use IDC/HTX files by reading about the Job Forum application. For information on the Job Forum application, see the Job Forum white paper, located at http://www.microsoft.com/accessdev/accwhite/jobforpa.htm. For applications that require many users to access the database simultaneously, you should consider upsizing the Microsoft Access database back-end server to Microsoft SQL Server. For information about upsizing a Microsoft Access Web application to Microsoft SQL Server, see http://www.microsoft.com/accessdev/accwhite/upsizeweb.htm.

Saving Forms and Datasheets as Active Server Pages

With Microsoft Access, you can save a form as an Active Server Page that emulates much of the functionality of your form. When saving a form as an Active Server Page, Microsoft Access saves most, but not all, controls on the form as ActiveX controls that perform the same or similar functions. Microsoft Access doesn’t save or run Visual Basic code behind the form or controls. To copy the layout of your form as closely as possible, Microsoft Access uses the Microsoft HTML Layout control to position the controls on Active Server Pages. The resulting page uses Visual Basic scripting and a feature of the Active Server Pages components called the Active Database Object (ADO) to connect to a copy of your database on an Internet server.

See Also   For information on the Microsoft HTML Layout control, see http://www.microsoft.com/workshop/author/layout/layout.htm.

Users who open a form saved as an Active Server Page can browse records, update or delete existing records, and add new records.

You can also save table, query, and form datasheets as Active Server Pages. When you open a datasheet saved as an Active Server Page, Microsoft Access displays current data from a copy of your database located on an Internet server, much like IDC/HTX files do. However, unlike IDC/HTX files, Active Server Pages require only one file per datasheet. The ASP file uses Visual Basic scripting to establish a connection to the database on the server, and contains information that it uses to format the datasheet. Unlike a form saved as an Active Server Page, users can’t update existing records in or add new records to a datasheet saved as an Active Server Page.

Û To save a form or datasheet as an Active Server Page

  1. In the Database window, click the form or datasheet you want to save.
  2. On the File menu, click Save As/Export.
  3. In the Save As dialog box, click To An External File Or Database, and then click OK.
  4. In the Save As Type box, click Microsoft Active Server Pages(*.asp).
  5. Specify the file name and location to save the file, and then click Export.
  6. In the Microsoft Active Server Pages Output Options dialog box, specify:
    • The data source name that will be used for a copy of the current database.
    • A user name and password, if required to open the database.
    • An HTML template, if you want Microsoft Access to merge one with the Active Server Page.

      See Also   For information on HTML templates, see “Using an HTML Template When You Save Data as HTML Documents” earlier in this chapter.

    • The URL for the server where the Active Server Page will reside.
    • The Session Timeout setting, which determines how long a connection to the server is maintained after the user stops working with the Active Server Page.
  7. Click OK.

You can also save forms and datasheets as Active Server Pages by using the Publish to the Web Wizard (available through the Save As HTML command on the File menu), the OutputTo method in code, or the OutputTo action in macros.

See Also   For more information on saving forms and datasheets as Active Server Pages, search the Help index for “saving database objects, saving in Internet/Web formats” or “OutputTo method.”

Form Views Supported for Active Server Pages

If the form you save as an Active Server Page has its DefaultView property set to Single Form or Continuous Forms, the Active Server Page displays as a single form, unless it is open in Datasheet view when you use the Save As/Export command (File menu). If the form has its DefaultView property set to Datasheet, the Active Server Page displays as a datasheet. Subforms always display as datasheets, regardless of their DefaultView property setting. All field data types are saved unformatted, that is, Format and InputMask property settings aren’t saved.

Control Types Supported for Active Server Pages

When Microsoft Access saves a form as an Active Server Page, it replaces Microsoft Access controls with ActiveX controls, as described in the following table.

Microsoft Access control ActiveX control
Text box Text box.
Text box control bound to a Hyperlink field Text box that displays the hyperlink text, but the hyperlink can’t be followed.
List box List box.
Combo box Combo box.
Label Label. If the label has HyperlinkAddress and/or HyperlinkSubAddress properties set, a hyperlink is created for the label.
Command button Command button, but any code behind the button isn’t saved. If the command button has HyperlinkAddress and/or HyperlinkSubAddress properties set, a hyperlink is created for the button.
Option group Option group, but without a group frame.
Option button Option button.
Check box Check box.
Toggle button Toggle button.
ActiveX control ActiveX control, but any code behind the control isn’t saved.
Subform Subform as datasheet only.

Microsoft Access doesn’t support the following controls when saving a form as an Active Server Page:

  • Tab controls, and anything on tab controls
  • Rectangles
  • Lines
  • Page breaks
  • Unbound object frames
  • Bound object frames
  • Image controls
  • The background of a form set with the Picture property

Note   You can simulate a rectangle or a line by using a label control without a caption.

Requirements for Using Active Server Pages

To display and use an Active Server Page, a copy of your database and Active Server Pages must reside on a computer running one of the following operating systems and Internet server platforms:

  • Microsoft Windows NT Server version 3.51 or 4.0 running Microsoft Internet Information Server version 3.0
  • Microsoft Windows NT Workstation version 4.0 and Microsoft Peer Web Services with the Active Server Pages components installed
  • Microsoft Windows 95 and Microsoft Personal Web Server with the Active Server Pages components installed

The Microsoft HTML Layout control must be installed on the computer opening the Active Server Page. The Active Server Pages components used to display Active Server Pages are available when installing Microsoft Internet Information Server version 3.0. To use Active Server Pages with Microsoft Peer Web Services or Microsoft Personal Web Server, you must install the Active Server Pages components as a separate add-in. Active Server Pages also require the Microsoft Access Desktop driver and a valid DSN to access a database.

See Also   For more information on installing Microsoft Peer Web Services or Microsoft Personal Web Server see “Setting Up a Personal Web Server” later in this chapter. For information on installing the Microsoft Access Desktop driver and defining DSNs, see “Requirements for Using IDC/HTX Files” earlier in this chapter.

See Also   For information on installing the Microsoft Access Desktop driver and defining DSNs, see “Requirements for Using IDC/HTX Files” earlier in this chapter.

Using the Publish to the Web Wizard

With the Publish to the Web Wizard, you can publish a set of Microsoft Access database objects to any combination of static HTML documents, IDC/HTX files, or Active Server Pages (ASP). Using the wizard, you can:

  • Pick any combination of tables, queries, forms, or reports to save.
  • Specify an HTML template to use for the selected objects.
  • Select any combination of static HTML documents, IDC/HTX files, or Active Server Pages (ASP).
  • Create a home page to tie together the Web pages you create.
  • Specify the folder where you save your files.
  • Use the Web Publishing Wizard to move the files created by the Publish to the Web Wizard to a Web server.
  • Save the answers you provide the wizard as a Web publication profile, and then select that profile the next time you use the wizard. This saves you from having to answer the wizard’s questions again.

To run the Publish to the Web Wizard, click Save As HTML on the File menu.

See Also   For more information on using the Publish to the Web Wizard, search the Help index for “Saving database objects, saving in Internet/Web formats.”

Synchronizing Database Replicas over the Internet

With Microsoft Access 97, you can synchronize replicas over the Internet. Before you can synchronize over the Internet, you must configure your Internet server for replication. To configure your Internet server, you need Replication Manager, which includes a wizard that takes you through the configuration process.

See Also   For more information on Replication Manager, see “Replication Manager” in Chapter 20, “Using Replication in Your Application.”

Importing, Linking, and Exporting Dataon the Internet

With Microsoft Access, you can import or link data from HTML tables or other data sources on an Internet server. You can also export data in your database to an Internet server.

Importing and Linking Data from HTML Tables

You can import or link data formatted as an HTML table to a Microsoft Access database. Before Microsoft Access imports or links the data, it copies the data into the local cache. Whenever you open a linked table, Microsoft Access makes a local copy from the original on the Internet or an intranet before opening it. For this reason, the data in the table is read-only. Similarly, if you export the linked HTML table to an HTML file, Microsoft Access exports it to a local file, not the original file on the Internet.

Û To import or link data from HTML tables

  1. On the File menu, point to Get External Data, and then click either Import or Link Tables.
  2. In the Files Of Type list, click HTML Documents (*.htm; *.html).
  3. Specify the file to import or link from by using any of the following methods:
    • Use the Look In box and the list of files below it to browse through the file system on your local hard drive or LAN.
    • In the File Name box, type a valid http:// or ftp:// URL.
    • In the Look In box, click Internet Locations (FTP) and select a previously defined FTP site.
    • In the Look In box, click Add/Modify FTP Locations, then specify a new FTP site and browse its files.
  4. Click Import or Link.

    See Also   For information on linking HTML files by using Visual Basic, see “Working with HTML Files” in Chapter 18, “Accessing External Data.”

When you import or link data from an HTML table, Microsoft Access parses the information contained within the HTML tags. The primary HTML tags that define tables are:

HTML tag pair Description
<TABLE>...</TABLE> Specifies the beginning and end of the table.
<TH...>...</TH> Specifies table header cells.
<TR...>...</TR> Specifies a row in a table.
<TD...>...</TD> Specifies table data cells.
<CAPTION...>...</CAPTION> Specifies the table’s caption, usually at the beginning or end of the table.

Microsoft Access applies the following rules when it interprets the progression of tags and tag pairs within the HTML table it imports or links:

  • The <TD> tag pair may be closed with either a </TD> tag or a </TH> tag.
  • The <TH> tag pair may be closed with either a </TH> tag or a </TD> tag.
  • The <TR> tag is not required to start a new row. If a <TD> tag follows a </TR> tag, Microsoft Access assumes this is the beginning of a new row.
  • If a </TABLE> tag is not preceded by a </TR> tag, then Microsoft Access assumes this is the end of the row.

In many cases, a table cell can display something other than text. If a table cell contains an embedded graphic file, there is a <IMG SRC...> tag associated with it. This tag may or may not have additional text that would be displayed. If additional text is present, Microsoft Access imports it, but Microsoft Access doesn’t import the embedded graphic and the tag that defines it. However, this is not true of embedded anchor <A HREF> tags; Microsoft Access imports anchor tags as Hyperlink fields.

HTML tables can contain lists that are embedded within a table cell. Lists in an HTML table cell are formatted with the <LI> and </LI> tags. Microsoft Access inserts a carriage return and line feed (<CR><LF>) after each list item and imports each item in the list as a separate field for that record.

HTML tables can also contain tables that are embedded within a table cell. You can import these as separate tables.

To achieve the most predictable results, import simple HTML tables with a fixed number of fields per record, without embedded lists or tables.

Exporting, Importing, and Linking Data fromOther Data Sources on Internet Servers

You can export any Microsoft Access-compatible external data file to an FTP server. You can’t export files to HTTP servers through the Internet, because you can’t write to them using the HTTP protocol.

Û To export data from external data sources on Internet servers

  1. On the File menu, click Save As/Export.
  2. In the Save As dialog box, click To An External File Or Database, and then click OK.
  3. In the Save As Type box, select the type of file you want to export.
  4. Specify an FTP server by using any of the following methods:
    • In the File Name box, type a valid ftp:// URL.
    • In the Save In box, click Internet Locations (FTP) and select a previously defined FTP site.
    • In the Save In box, click Add/Modify FTP Locations, then specify a new FTP site and browse its files.
  5. Click Export.

You can also import and link any Microsoft Access-compatible external data file, except Microsoft Access databases and ODBC data sources, by using an FTP or HTTP connection. An FTP or HTTP connection is only maintained long enough to perform a single transaction. Therefore, when you import or link a file located on an FTP or HTTP server, Microsoft Access copies the data file to the user’s local cache. Microsoft Access then imports or links to the data file in the local cache. For this reason, files linked with an FTP or HTTP connection are read-only.

Û To import or link data from external data sources on Internet servers

  1. On the File menu, point to Get External Data, and then click either Import or Link Tables.
  2. In the Files Of Type list, select the type of file you want to import or link.
  3. To specify an FTP server, use any of the following methods:
    • In the File Name box, type a valid ftp:// URL.
    • In the Look In box, click Internet Locations (FTP) and select a previously defined FTP site.
    • In the Look In box, click Add/Modify FTP Locations, then specify a new FTP site and browse its files.

    To specify an HTTP server:

    • In the File Name box, type a valid http:// URL.
  4. Click Import or Link.

Using the WebBrowser Control

The Microsoft WebBrowser control is an ActiveX control that you can use on your application’s forms to browse Web sites, view Web pages and other documents, and download data located on the Internet. The WebBrowser control is useful in situations where you don’t want to disrupt the work flow in your application by switching from Microsoft Access to a Web browser or other document-viewing application.

The WebBrowser control can display any Web page that Microsoft Internet Explorer version 3.0 can display. For example, the WebBrowser control can display pages that include any of the following features:

  • Standard HTML and HTML enhancements, such as floating frames and cascading style sheets
  • Other ActiveX controls
  • Most Netscape plug-ins
  • Scripting, such as Microsoft Visual Basic Scripting Edition (VBScript) or JavaScript
  • Java™ applets
  • Multimedia content, such as video and audio playback
  • Three-dimensional virtual worlds created with Virtual Reality Modeling Language (VRML)

In addition to opening Web pages, the WebBrowser control can open any ActiveX document, which includes most Microsoft Office documents. For example, if Microsoft Office is installed on a user’s computer, an application that uses the WebBrowser control can open and edit Microsoft Excel spreadsheets, Microsoft Word documents, and Microsoft PowerPoint presentations from within the control. Similarly, if Microsoft Excel Viewer, Microsoft Word Viewer, or Microsoft PowerPoint Viewer is installed, users can view those documents within the WebBrowser control.

With the WebBrowser control, users of your application can browse sites on the World Wide Web, as well as folders on a local hard disk and on a local area network. Users can follow hyperlinks by clicking them or by typing a URL into a text box. Also, the WebBrowser control maintains a history list that users can browse through to view previously browsed sites, folders, and documents.

Note   Additional ActiveX controls that you can use to work with content on the Internet or an intranet are available in Microsoft Office 97, Developer Edition.

Adding the WebBrowser Control to a Form

Before you can add the WebBrowser control to a form, you must have Microsoft Internet Explorer version 3.0 or later installed.

If you purchased Microsoft Office 97 on CD-ROM, you can install Microsoft Internet Explorer version 3.01 by running Msie301.exe from the Iexplore subfolder in the ValuPack folder.

If you purchased Microsoft Access 97 on floppy disks, or if you prefer to install from the Web, you can download and install the latest version of Microsoft Internet Explorer from http://www.microsoft.com/ie/download/.

Once you have Microsoft Internet Explorer version 3.01 installed, the WebBrowser control is automatically registered and is available in form Design view.

Û To add the WebBrowser control to a form

  1. Open the form in Design view.

  2. In the toolbox, click the More Controls tool.

    A menu appears that lists all the registered ActiveX controls in your system.

  3. On the menu of ActiveX controls, click Microsoft WebBrowser Control.
  4. On the form, click where you want to place the control.
  5. Move and size the control to the area you want to display.

Tip If the WebBrowser control can’t display the full width or height of a Web page or document, it automatically displays scroll bars. However, in most cases, you should make the control wide enough to display the full width of a typical Web page so that users of your application don’t have to scroll horizontally.

Note   After you add a WebBrowser control to a form and save the form or display it in Form view, the control retains its original size even when you re-open the form in Design view and resize the control. To resize the control, delete the existing control, add a new control, and then resize the new control and set its properties before saving the form.

Displaying Web Pages or Documents in the WebBrowser Control

To display a Web page or document in the WebBrowser control, use the Navigate method in Visual Basic. The syntax for the Navigate method is:

object.Navigate URL

Object is either the name of the WebBrowser control on your form or an object variable that refers to it, and URL is a string expression that evaluates to a valid URL or path. URL can refer to a Web page or other content on the Internet or an intranet, as well as to an Office document, such as a Microsoft Word document.

If URL refers to an Internet protocol and a location on the Internet, Microsoft Access must establish a connection before is can display the document. If the computer running your application is connected to a proxy server (a secure connection to the Internet through a LAN), or if it has a direct connection to the Internet, the WebBrowser control downloads and displays the Web page or other Internet content immediately. If the computer running your application uses a modem and dial-up connection to the Internet, and that connection hasn’t been established beforehand, the WebBrowser control initiates the connection. For example, if the user’s computer uses a modem and The Microsoft Network to connect to the Internet, the Sign In dialog box is displayed to establish the connection to the Internet before the WebBrowser control can display Internet content.

If URL refers to an Internet protocol and a location on an intranet server, the computer running your application must be connected to the intranet and have permission to access that server.

If URL refers to a standard file system path on a local hard drive or intranet, the WebBrowser control opens the document and displays it immediately. The WebBrowser control can open Microsoft Office documents, text files, and HTML documents that don’t require features supported only by an Internet server. For example, the WebBrowser control can’t open HTML documents that use IDC/HTX files or Active Server Pages (ASP) files from the standard file system, but it can open HTML documents that contain only the HTML tags supported by Microsoft Internet Explorer version 3.0.

Note   If URL refers to a path in the standard file system that doesn’t refer to a file name (for example, C:\Windows\System\), the WebBrowser control displays the file system itself, much like My Computer.

Displaying a Document in the WebBrowser Control by Using an Address in a Text Box

Using the WebBrowser control, you can create a form that performs most of the functions of Microsoft Internet Explorer version 3.0. For example, the following illustration shows the Custom Browse form (WebBrowseWeb) in the Developer Solutions sample application.

When a user types a valid URL in the text box at the top of the form (txtLinks) and presses ENTER, the WebBrowser control (ActiveXCtl1) displays the Web page or document. Pressing ENTER triggers the AfterUpdate event of the txtLinks text box; the AfterUpdate event contains the following code which navigates to the URL entered by the user:

Private Sub txtLinks_AfterUpdate()
On Error Resume Next
	If Len(Me!txtLinks) > 0 Then
		Me!ActiveXCtl1.Navigate Me!txtLinks
	End If
End Sub

Error handling is passed to the control itself because it displays the same error messages displayed by Microsoft Internet Explorer version 3.0.

If you prefer to start navigation by clicking a command button instead pressing ENTER, you can use similar code in the button’s Click event.

The Home, Back, Forward, Refresh, and Search buttons on the Custom Browse form use the corresponding GoHome, GoBack, GoForward, Refresh, and GoSearch methods of the WebBrowser control.

See Also   For information on how to view brief descriptions about the properties, methods, and events of the WebBrowser control, see “Viewing Descriptions of the Properties, Methods, and Events of the WebBrowser Control” later in this chapter.

With the Save Location button on the Custom Browse form, you can save the address and a description of the current document to the Links table in the Developer Solutions database. When you click the Save Location button, Microsoft Access checks to see if the URL has been saved previously, and if not, uses the following statement to open the Save Location To Table dialog box:

DoCmd.OpenForm "frmSaveURLDialog", acWindowNormal, , , acFormEdit, acDialog, _	ctlHyper.LocationName & ";" & ctlHyper.LocationURL

The last argument of this statement (ctlHyper.LocationName & ";" & ctlHyper.LocationURL) sets the OpenArgs property to a concatenated string that contains the two values returned by the LocationName and LocationURL properties of the document currently displayed in the Custom Browse form. When the Save Location To Table dialog box opens, code in its Load event parses the OpenArgs property value back into two parts and displays them as the default description and address. When the user clicks OK, the description and address in the Save Location To Table dialog box form are saved in the Hyperlink and Description fields in the Links table.

See Also   For more information on the Custom Browse form, open the Developer Solutions sample application located in the Samples subfolder of your Office folder.

Displaying a Document in the WebBrowser Control by Using a Hyperlink Stored in a Table

Using the WebBrowser control, you can create a form that displays documents specified in hyperlinks stored in a table. For example, the following illustration shows the Browse Saved Hyperlinks (WebBrowseTable) form in the Developer Solutions sample application. You can use the Browse Saved Hyperlinks form to browse addresses saved in the Links table.

When a user clicks a record navigation button at the bottom of the form to move to a new record, the following code in the form’s Current event displays the Web page or document whose address is stored in the current record.

Private Sub Form_Current()
	Dim varFull As Variant, varDescription As Variant
	Dim HyperlinkAddress As String, HyperlinkSubAddress As String
	Dim msg1 As String, msg2 As String, rst As Recordset, strDisplay As String
	
	On Error Resume Next

	Set rst = Me.RecordsetClone
	rst.Bookmark = Me.Bookmark
	varFull = rst!HyperLink

	If IsNull(varFull) Then GoTo Current_Err
	varDescription = rst!Description
	Me!ActiveXCtl1.Navigate HyperlinkPart(varFull, acAddress)

	If Err = 438 Then Exit Sub

	gvarBookMark = Me.Bookmark

Current_Bye:
	Exit Sub
Current_Err:

msg1 = "Invalid hyperlink address. Remove the record described as '"
msg2 = "' from the Links table or edit the hyperlink to supply a valid address."

MsgBox msg1 & rst!Description & msg2
	
		Me.Bookmark = gvarBookMark
		Exit Sub
End Sub

This procedure uses the Navigate method of the WebBrowser control to display the next hyperlink address. However, don’t pass the contents of a Hyperlink field directly to the Navigate method. If a user enters or edits data stored in a Hyperlink field from a datasheet or form, it may contain up to three parts of information separated by the number sign (#). Even if the user doesn’t enter all three parts in the datasheet or form, Microsoft Access automatically stores number signs in the field. If there are number signs in the Hyperlink field, passing the data from the field directly to the Navigate method generates an error. To handle this, the stored value is passed to the HyperlinkPart function to extract the address portion of the saved hyperlink, which is then passed to the Navigate method. If navigation is successful, the form’s Bookmark property value is stored in a public variable. This public variable is used to return to the last record if subsequent navigation fails.

Using code to save data in a Hyperlink field doesn’t automatically save number signs in the field. To preserve the proper functioning of a Hyperlink field in other contexts, you may want to write your code to save number signs before and after a hyperlink address. For an example of how to do this, see the event procedure set for the Click event of the Save Location button (cmdSaveLocation) on the Custom Browse form.

Note   You don’t have to store addresses in a Hyperlink field if you don’t need users to be able to navigate to addresses by clicking them in datasheets or forms, or if you don’t need to save addresses as HTML anchor tags when saving as HTML. As long as an address doesn’t exceed 255 characters, you can store it in a Text field. If an address exceeds 255 characters, you can store it in a Memo field. In either case, you can pass the value stored in the field directly to the Navigate method.

See Also   For more information on the Browse Saved Hyperlinks form, open the Developer Solutions sample application located in the Samples subfolder of your Office folder. For more information on the format of data stored in a Hyperlink field, see “The Hyperlink Field Storage Format” earlier in this chapter.

Viewing Descriptions of the Properties, Methods, and Events of the WebBrowser Control

Like built-in Microsoft Access objects, the WebBrowser control has properties that your application can set or read to determine the control’s characteristics, methods that your application can use to perform operations on the control, and events your application can respond to. You can view brief descriptions of the properties, methods, and events of the WebBrowser control by using the Object Browser.

Important In order for these properties, methods, and events to appear in the Object Browser, you must set a reference to the Microsoft Internet Controls object library. To set this reference, open a module, click References on the Tools menu, and select the Microsoft Internet Controls check box in the Available References box.

Û To view descriptions of the WebBrowser control’s methods, properties, and events

  1. Open a module.
  2. On the View menu, click Object Browser.
  3. In the Project/Library box, click SHDocVw.
  4. In the Classes box, click WebBrowser.

    The Members Of box lists the methods, properties, and events associated with the WebBrowser control.

See Also   For more information on the methods, properties, and events of the WebBrowser control, see http://www.microsoft.com/intdev/sdk/docs/iexplore/. If you purchased Microsoft Access 97 on CD-ROM, you can view a Help file that contains this information by opening the \ValuPack\Access\Webhelp folder on the Setup CD-ROM, and then copying the Iexplore.hlp and Iexplore.cnt files to your hard disk.

Distributing the WebBrowser Control with Your Application

Unlike most other ActiveX controls, you can’t install the WebBrowser control by itself. For an application that uses the WebBrowser control to work, Microsoft Internet Explorer version 3.0 must also be installed on the computer. Microsoft Internet Explorer version 3.0 can be distributed freely, and doesn’t require the payment of royalties or other licensing fees.

See Also   For information on installing Microsoft Internet Explorer version 3.0, see “Adding the WebBrowser Control to a Form” earlier in this chapter.

Setting Up a Personal Web Server

Microsoft provides two products that make it easy to create a personal Web server on your computer for low-volume Web publishing: Microsoft Personal Web Server and Microsoft Peer Web Services. These products are ideal for publishing departmental home pages, personal home pages, or small-scale Web applications on your company’s intranet.

Although Personal Web Server and Peer Web Services are intended for small-scale Web publishing, they provide most of the same services and features as Microsoft Internet Information Server, a robust Web server intended for high-volume Web publishing. You can use Personal Web Server or Peer Web Services to develop and test your Web applications, and then transfer them to a Web server running Microsoft Internet Information Server.

Both Personal Web Server and Peer Web Services can:

  • Publish Web pages on the Internet or over a LAN on an intranet by using the HTTP service.
  • Support Microsoft ActiveX controls.
  • Transmit or receive files by using the FTP service.
  • Run Internet Server API (ISAPI) and Common Gateway Interface (CGI) scripts.
  • Send queries to ODBC data sources by using the Internet Database Connector component (Httpodbc.dll).
  • Support the Secure Sockets Layer.

In addition, Peer Web Services can:

  • Use pass-through security to Windows NT Server and Novell NetWare.
  • Use local-user security if Microsoft File and Print Sharing are not installed.
  • Perform remote administration by using a Web-based application.
  • Distribute documents by using the Gopher service.

Installation Requirements

To run Personal Web Server or Peer Web Services, you must meet the following installation requirements.

Personal Web Server

  • A computer with Windows 95 installed.
  • A CD-ROM drive for the installation compact disc.
  • Adequate disk space for your information content.

Peer Web Services

  • A computer with Windows NT Workstation version 4.0 installed.
  • A CD-ROM drive for the installation compact disc.
  • Adequate disk space for your information content. It is recommended that all drives used with Peer Web Services be formatted with the Windows NT File System (NTFS).

Publication Requirements

When using Personal Web Server or Peer Web Services, each computer you want to access the server must have Transmission Control Protocol/Internet Protocol (TCP/IP) installed. The TCP/IP protocol is included with Windows 95 and Windows NT Workstation version 4.0. To install and configure the TCP/IP protocol and related components, double-click the Network icon in Control Panel. Each system must meet additional requirements depending on whether you want to use the server on an intranet or the Internet.

Intranet Publication Requirements

  • A network adapter card and local area network (LAN) connection.
  • The Windows Internet Name Service (WINS) server or the Domain Name System (DNS) server installed on a computer in your intranet. WINS and DNS run only on Windows NT Server. This step is optional, but it does allow users to use “friendly names” instead of IP addresses when connecting to your server.

Internet Publication Requirements

  • An Internet connection and Internet Protocol (IP) address from your Internet Service Provider (ISP).
  • DNS registration for that IP address. This step is optional, but it does allow users to use “friendly names” instead of IP addresses when connecting to your server. For example, “microsoft.com” is the friendly domain name registered to Microsoft. Within the microsoft.com domain, Microsoft has named its World Wide Web (WWW) server “www.microsoft.com.” Most ISPs can register your domain names for you.
  • A network adapter card suitable for your connection to the Internet.

Installing Personal Web Server

The Setup file for the Personal Web Server is available on the Web. To download the Setup program for Personal Web Server for Windows 95, connect to the Microsoft Personal Web Server home page at:

http://www.microsoft.com/ie/iesk/pws.htm

You can install Personal Web Server if you are running Windows 95 or Windows NT Workstation version 4.0. However, if you are using Windows NT, it is recommended that you install Peer Web Services instead.

Û To install Personal Web Server

  1. Connect to the Personal Web Server home page on the Web and download PWS10a.exe.
  2. Double-click PWS10a.exe.

    This starts the installation process. You may be required to supply additional files from your Windows 95 Setup disks.

  3. When installation is finished, the Setup program asks if you want to restart your computer. Click Yes.

Installing Peer Web Services

The files to install Peer Web Services are provided on the Microsoft Windows NT Workstation version 4.0 Setup CD-ROM.

Û To install Peer Web Services

  1. Click the Windows Start button, point to Settings, and click Control Panel.
  2. Double-click Network.
  3. Click the Services tab, and then click Add.
  4. In the Network Service list, double-click Peer Web Services.

    This starts the installation process. You may be required to supply additional files from your Windows NT Setup disks.

  5. In the first Microsoft Peer Web Services Setup dialog box, click OK.
  6. In the second Microsoft Peer Web Services Setup dialog box, select which services you want to install, and then click OK.
  7. In the Publishing Directories dialog box, specify the directories you want to use for each service, or accept the default directories, and then click OK.

Getting More Information

For more information about Using Personal Web Server or Peer Web Services, you can refer to their online documentation, which is available once installation is complete.

Û To view documentation for Personal Web Server or Peer Web Services

  1. Start your Web browser.
  2. To view the documentation for Personal Web Server, in your browser’s address box, type:

    http://MyServer/docs/default.htm

    To view the documentation for Peer Web Services, in your browser’s address box, type:

    http://MyServer/iisadmin/htmldocs/inetdocs.htm

    where MyServer is the name of the computer on which you installed Personal Web Server or Peer Web Services. To determine the name of the computer, open Control Panel, double-click the Network icon, and then click the Identification tab.

  3. Press ENTER.

Using Active Server Pages with Personal Web Server or Peer Web Services

If you want to use Active Server Pages with either Personal Web Server or Peer Web Services, you must install the Active Server Pages components after installing your server software. These components are not distributed with the Setup programs for Personal Web Server or Peer Web Services. To download the Setup program for these components, connect to http://www.microsoft.com/msdownload/iis_asp.htm.

Note   To install the Active Server Pages components for Personal Web Server running on Windows 95, download the Active Server Pages for Windows NT (i386) Setup files.

See Also   For more information on the Internet Information Server version 3.0 and the Active Server Pages components, connect to http://www.microsoft.com/iis/default.asp.