Brett A. Tanzer, Microsoft Access Program Manager
Microsoft Corporation
January 1999
Microsoft® Access data access pages are documents that allow users to combine the rich features of a dynamic HTML (DHTML) document with data stored in either a Microsoft Access or Microsoft SQL Server™ database. The tools provided in the data access page design environment make it easy for users with varying degrees of experience to create these documents and deploy them on a local file system, a network server, or a Web server inside their organizations.
Access provides an extensive feature set that allows users to add varying degrees of interactivity to their documents. Authors can create pages that are used for entering and updating data or they can create grouped pages that rely on either specific criteria or on the relationships in the database to organize the data in a hierarchical format. Data access pages can also take full advantage of the Microsoft Office Web Components, each of which adds different analytical functionality to a page. Combining different types of pages together can result in powerful solutions that leverage the best of the various Web technologies along with the power of a relational database.
Because data access pages are based on the DHTML Document Object Model (DOM), authors and developers have access to this expansive feature set and can create documents that use the DOM in many ways. This paper focuses on how you can connect data access pages together, either by using the tools provided in the Microsoft Access design environment, or by manipulating the DOM through scripting technologies, such as Microsoft Visual Basic® Scripting Edition (VBScript) and Microsoft JScript®.
Hyperlinks are the standard method used to connect Web pages today. Data access pages provide full support for hyperlinks and a complete set of tools for editing and augmenting them inside the design environment.
The data access page toolbox provides three distinct tools for creating hyperlink controls: the Hyperlink tool, the Bound Hyperlink tool, and the Hotspot Image tool.
Hyperlink tool. A hyperlink is a pointer from text in a document to a Web page or other type of file on the World Wide Web or other shared location. You can customize the hyperlink's target location, display text, and ToolTip (the text that is displayed when the mouse pointer rests on the hyperlink). When clicked, the hyperlink navigates to the targeted document.
Bound Hyperlink tool. Bound hyperlinks provide the same functionality at run time as regular hyperlinks do; however the target location and display text may both be populated from a field in the database to which the page is bound.
Hotspot Image tool. Hotspot images provide similar functionality to hyperlinks, except that the display text is replaced with an image that navigates to the targeted document when clicked.
Both the hyperlink and hotspot image controls use the Insert Hyperlink dialog box to make it easy for you to specify the necessary information. Properties for the bound hyperlink control can be set by selecting the control and setting these properties directly through the control's property sheet. General usage for each of these controls is documented fully in the Help system provided with Access.
This section focuses on the specific set of features in the Insert Hyperlink dialog box that allow you to use a hyperlink to connect data access pages and simultaneously filter the records displayed in the target data access page.
Suppose you have the data access pages shown in Figures 1 and 2.
Figure 1. The Northwind Customers page, which displays customer contact information in a scrollable page populated from the Customers table in the Northwind Traders sample database.
Figure 2. The Northwind Orders page, which displays a continuous list of the orders stored in the Orders table of the Northwind database.
Ideally, users should have some mechanism to locate to a record of interest in the Northwind Customers page and then navigate to a new page that displays only the orders for the selected customer. The Insert Hyperlink dialog box makes it easy to create a hyperlink that serves this purpose.
You can specify filter criteria in the form of an SQL WHERE clause that is passed to the target page as part of the hyperlink. That criteria, known as a server filter, is used by the target page to filter its recordset before the records are retrieved from the database.
CustomerID='[CustomerID]'
will yield CustomerID='ALFKI')
.Figure 3. Using the Insert Hyperlink dialog box to create a hyperlink that uses a server filter
As shown in Figure 4, when users run the Northwind Customer page and click the hyperlink, they end up with a view that is filtered based on a value in the current document.
Figure 4. The Northwind Orders page filtered by using a value specified on the source page
CustomerID='[CustomerID]' AND ShipVia=[Shipper]
By using hyperlinks, you can build many powerful solutions without writing any scripting code or editing any HTML. However, by creating advanced HTML pages that use frame sets or using the window-management methods provided by the DHTML DOM through script, you can create many more powerful scenarios.
On the Web today, frame sets are a common user-interface convention that enables you to combine functionality packaged inside individual Web pages into a single view. Although the data access page design environment in Access does not natively support HTML frame set editing, other Office applications, such as Microsoft Word and Microsoft FrontPage®, do. Since data access pages are HTML documents, they can be easily hosted inside any frame set. For details about creating the frame set document itself, see the documentation provided with your HTML frame set editor.
This section discusses the operation of data access pages inside the frame set, and what specific tasks are required to enable your data access pages to function properly inside a framed environment.
Suppose you have a very simple frame set (shown in Figure 5) that contains two frames, one named Left and one named Right.
Figure 5. Simple frame set
This frame set is defined by the following HTML code:
<HTML>
<HEAD>
<TITLE>Northwind Customer Information</TITLE>
</HEAD>
<FRAMESET COLS=300,* >
<FRAME NAME=LEFT src="Northwind Customers.htm" scrolling=yes>
<FRAME NAME=RIGHT src="Northwind Orders.htm " scrolling=no>
</FRAMESET>
</HTML>
Note that the SRC attribute of each frame specifies the data access page to load, and that each frame has a name specified. Suppose you want to enable users to locate a particular customer in the Northwind Customers data access page hosted in the frame named Left
, then allow them to click a hyperlink that opens the Northwind Orders data access page in the frame named Right
, filtering the data appropriately, as shown in Figure 6.
Figure 6. Data access pages in a frame set that displays filtered information passed between frames through a hyperlink
In addition to using the name of a frame inside the frame set document, Internet Explorer allows you to choose from a list of predefined values for the Target property that define additional behavior. Full details can be found in the Internet Client SDK at http://msdn.microsoft.com/workshop/essentials/inetsdk/inetsdk_map.asp. Table 1 provides a summary of these values.
Table 1. Possible values for Target property of a hyperlink
Value | Description |
Frame Name | String value representing the name of a valid frame in which to load the frame set. |
_blank | Specifies to load the linked document into a new blank window. This window is not named. |
_parent | Specifies to load the linked document into the immediate parent of the document the link is in. |
_search | Specifies to load the linked document into the browser's search pane. Available in Internet Explorer 5 or later. |
_self | Specifies to load the linked document into the same window the link was clicked in (the active window). |
_top | Specifies to load the linked document into the topmost window. |
You may want to create a multiwindowed environment instead of a frame set for a variety of reasons, such as wanting to present a more traditional UI, wanting to use a modal window to enforce application flow, or wanting to use a modeless window that is always available as part of the application. You can accomplish all of these tasks by using several scriptable methods exposed by the DOM. This section covers those methods and their usage at a high level. Full details and samples can be found in the Internet Explorer Client SDK at http://msdn.microsoft.com/workshop/essentials/inetsdk/inetsdk_map.asp.
The DOM supports three methods that allow you to manage windows as part of your application:
You traditionally use the open method to open a new window that displays a new document when you want to manipulate properties, methods, and events in the target document from script residing in the source document. Of the three window-management methods, this is the only one that will allow you to reference objects in the target document from "local" script.
This method is particularly useful when you would like to dynamically set server filters, sort orders, and so on, in the target page.
The following script opens the Northwind Orders page from the Northwind Customers page and sets the field used in the sort order to ShipDate.
<SCRIPT Language=VBScript>
<!--
Sub OpenPage()
Dim newWin
Dim myDSC
Set newWin=window.open("Northwind Orders.htm",null, _
"height=200;width=200;status=no,toolbar=no,menubar=no," _
& "location=no")
Set myDSC=newWin.document.all.MSODSC
myDSC.defaultRecordset.sort="ShipDate"
End Sub
-->
</SCRIPT>
The showModalDialog and showModelessDialog methods are used to open a dialog box window and affect its modality. This can be useful when you want to force the user of your application to take an action before continuing or, conversely, if you want to open a dialog box that is always available. These methods allow you to control the appearance and behavior of the dialog box at a very granular level. These methods do not allow you to access objects in the dialog box from script in the document that opened the dialog box. You can, however, set the returnValue property for the dialog box, which, in turn, is passed out of the call that invoked the dialog box.
In the following example (shown in Figure 7), a page that displays Orders and OrderDetails (the source page) opens a modal dialog box (the target page) that is bound to the OrderDetails table. The target page is opened in data-entry mode and is titled Products.
Figure 7. A data access page connected to another data access page that's presented in a modal dialog box
The script in the source page does the following:
The script in the target page does the following:
The script used in the source and target pages is as follows:
<SCRIPT id=clientEventHandlersVBS language=vbscript>
<!--
Sub Command0_onclick
newDlg=window.showModalDialog _
("http://yourservername/nwindorders/Products.htm", _
document.all.OrderId.value, _
"dialogWidth:22;dialogHeight:22;center:yes")
If newDlg = True Then
window.location.reload()
End If
End Sub
-->
</SCRIPT>
<SCRIPT id=clientEventHandlersVBS language=vbscript>
<!--
Sub Command0_onclick
window.OrderID.value = window.dialogArguments
window.MSODSC.CurrentSection.DataPage.Save()
window.MSODSC.CurrentSection.DataPage.NewRecord()
window.returnValue = True
End Sub
Sub Command1_onclick
window.close()
End Sub
-->
</SCRIPT>
We have examined only a few of the techniques you can use to create rich and interesting applications with data access pages. Extending these documents with script, frames, and dialog boxes are only some of the options available to you. For more information about extending data access pages, see the following resources:
---------------------------------------------
The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, this paper should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT.
Microsoft, FrontPage, JScript, Microsoft Press, and Visual Basic are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.