Working with Data Access Pages in FrontPage 2000

 

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Roy Leban
Microsoft Corporation

Created: January 1999
Revised: September 1999

Note

   

The original version of this article included sections on working with data access pages on the Internet or an intranet. Those sections have been rewritten by Mark Roberts and moved into a separate article titled Deploying Data Access Pages on the Internet or Your Intranet.

Applies To: Microsoft Access 2000; Microsoft FrontPage 2000; Microsoft Internet Explorer 5; Microsoft Internet Information Server 4.0

Summary: This article shows you how to use Microsoft® FrontPage® to edit and enhance your data access pages, and how to use frames and server filters to create an easy-to-use and easy-to-navigate Web site. (12 printed pages)

Contents

Introduction Getting Started Using FrontPage with Data Access Pages Next Steps

Introduction

Data access pages in Microsoft® Access 2000 allow you to make your data available to anybody who has Microsoft Internet Explorer 5 and a Microsoft Office license. When you combine Access with FrontPage® 2000 and Microsoft Internet Information Server (IIS) version 4.0 or later, you'll have all the tools you need to create a dynamic Web site that serves data from Access or Microsoft SQL Server™ databases.

**Note   **For security information about working with Web sites and Web servers, see FrontPage Security Best Practices.

What This Paper Isn't

This paper won't make you an expert on FrontPage, IIS, or managing a Web site. For complete information about FrontPage and IIS, consult the documentation that comes with those products. If you're new to the Web, you'll probably want to pick up a book about FrontPage and/or Web site creation. Additional resources for working with data access pages and Web sites are listed in the "Next Steps" section at the end of this paper.

Getting Started

As part of the Microsoft product family, Access works with all the other products you'll use to build a Web site.

Microsoft FrontPage

FrontPage 2000, part of the Microsoft Office 2000 Premium package, allows you to create engaging Web sites that look and work exactly the way you want them to. FrontPage includes the ability to lay out pages with exacting care, design the pages with elements that color-coordinate, and use such cutting-edge features as dynamic HTML (DHTML) and cascading style sheets, which add style, movement, and interest to Web pages. The FrontPage Explorer, which is integrated into FrontPage 2000, makes it easy to manage the pages and the navigation structure of your Web site.

FrontPage also includes publishing features that make it easy to post your site to your Web server, as well as collaboration features. Because FrontPage 2000 preserves all foreign HTML, including formatting, you can use FrontPage 2000 to edit and enhance data access pages without any loss of functionality.

Microsoft Internet Information Server and Microsoft Site Server

Microsoft Internet Information Server (IIS) is built into the Microsoft Windows NT® Server operating system. It was designed to deliver the highest level of security for corporate intranets and the Internet. Additionally, IIS provides a high-performance implementation of Secure Sockets Layer (SSL) 3.0 for secure communication and authentication with X.509 certificates, RSA public-key cipher, and a broad array of additional security features. IIS is a comprehensive platform for rapidly building Web sites that are secure for both Internet and intranet use.

Microsoft Site Server 3.0, a separate product optimized for use with IIS, adds publishing and searching capabilities and personalized delivery. Microsoft Site Server 3.0 Commerce Edition adds transaction capabilities for secure online commerce.

Microsoft Personal Web Server

For low-use Web sites, or for sites on an intranet, you can use Microsoft Personal Web Server with Microsoft Windows® 95 or 98, or Microsoft Windows NT Workstation. Personal Web Server is simpler to install and administer than Internet Information Server, but because it was not designed to support high-volume Web sites, it does not include support for three-tier data access or use with Site Server. Personal Web Server also does not offer some of the security features found in IIS.

Using FrontPage with Data Access Pages

It's easy to edit your Web pages in both Access and FrontPage, but there are a few simple rules to follow.

Editing Data Access Pages in FrontPage

When you open a data access page in FrontPage, FrontPage detects that the document is a data access page and automatically launches Access so you can edit the page. If you want to edit a data access page in FrontPage, click Open on the File menu, select the .htm file, click the arrow to the right of the Open button, and then click Open in Microsoft FrontPage.

Figure 1. File menu option to edit data access page in FrontPage

**Tip   **If you add a data access page to a FrontPage-based Web site, you can open the data access page by double-clicking it in any FrontPage view.

At the bottom of the Page view window in FrontPage, you'll find the Normal and Preview tabs, which are analogous to the Design and Page views in Access. In addition, you'll find an HTML tab, which you can use to display the HTML code that makes up your data access page.

The Normal tab provides all of the FrontPage editing tools for your page, including frames, tables, styles, dynamic effects, transitions, and navigation bars. Many HTML features that can be accessed only from the property sheet in Access are available through the FrontPage formatting tools.

The Preview tab provides an easy way to try out your page without saving it and returning to Access or running Internet Explorer.

The HTML tab allows you to view and edit the HTML and XML code that makes up your data access page. You can use this tab to add or edit scripts for your page, though you'll probably find the Microsoft Script Editor better for that purpose. To open the Script Editor, press ALT+SHIFT+F11.

If you view your data access page by clicking the HTML tab, you'll notice that your page contains a lot of text that doesn't look like HTML tags, as shown below.

<PARAM name="XMLData" value="&lt;?xml:namespace ns=&quot;urn:schemas-microsoft-com:office:access&quot; prefix=&quot;a&quot;?&gt;
&lt;xml&gt;
 &lt;a:DataSourceControl&gt;
  &lt;a:OWCVersion&gt;9.0.0.2209&lt;/a:OWCVersion&gt;

This text is the Extensible Markup Language (XML) representation of the data definition for the page. Be careful not to alter the XML code, or your data access page may not work when you return to Access or view it in Internet Explorer.

When you are moving between Access and FrontPage, make sure to close your data access page in Access before opening it in FrontPage, and vice versa. If you don't do so, you may not be able to save changes you make.

**Note   **If you are using FrontPage or Internet Explorer to view a data access page that uses an Access database (.mdb file), the page will access your database directly. This means that you won't be able to make design changes in your database, including creating links to new data access pages. If you get an error message that says the database can't be put into exclusive mode, close any windows in which you are viewing the data access page, and try the operation again. This behavior occurs only with Access databases; it does not occur when you are using SQL Server databases.

Editing FrontPage Pages in Access

If you're integrating database access into an existing Web site, you may find it easier to start in FrontPage and then edit the appropriate pages in Access. This will be especially true if you're using frames or have a complex Web site. When you use Access to open and modify a Web page that was created in FrontPage, the page will automatically be converted into a data access page, and the DataSourceControl object necessary for data binding will be added. To edit the Web page in Access, do the following:

  1. In the Access Database window, click Pages in the Objects bar, double-click Edit Web page that already exists, and then select the .htm file.
  2. If you want to use fixed positioning for your controls, click Unbound Section on the Insert menu. This will add a section at the end of your page that contains a grid where you can position controls however you like. Controls added outside this section are positioned by using standard HTML layout.
  3. Start adding your data as you would with any other data access page.

The grid section is added at the end of your page. If you want your data to be within your FrontPage layout (for example, inside a table), you'll need to move the grid. The easiest way to do this is to use FrontPage as follows:

  1. Save and close the page in Access.

  2. Reopen the page in FrontPage.

  3. In Page view, click the HTML tab, and then scroll to the bottom, where you'll find text that looks like the following:

    <DIV class=MicrosoftAccessBanner id=HeaderFoodsBanner ...>
    Section: Foods</DIV>
    <DIV class=MSOShowDesignGrid id=HeaderFoods ...>
        (any objects you've added are here)
    </DIV>
    

    The first <DIV> is the section banner above the grid that is shown in Design view; the second <DIV> is the grid where you can position controls. The actual HTML code will be a lot more complicated than what is shown above because it will include all the size and positioning attributes.

  4. Cut everything from the first <DIV> tag to the end of the second closing </DIV> tag.

  5. Click the Normal tab, and position the insertion point where you want your data to appear.

  6. On the Edit menu, click Paste Special, click Treat as HTML, then click OK. You may want to resize the grid to get it to fit in your layout.

  7. Save the page. You can now return to Access and add your data-bound controls.

The Default Editor

Microsoft Office uses the content of your Web page, not just the .htm or .html suffix, to determine which application to edit the page in. Whenever you edit a Web page in either Access or FrontPage, that editor will become the default editor for that page.

Effective Use of Frames

Many Web sites make use of frames to maintain a standard interface while showing a variety of content. When combined with server filters in data access pages, frames enable you to create a dynamic Web site that allows easy navigation. The best way to create a frame-based site is to start in FrontPage and create your frame set and the basic set of pages. Next, open up each page you want to use with bound data and convert it into a data access page, as described earlier in "Editing FrontPage Pages in Access." Finally, add the appropriate links and code to the navigation page to activate the data-bound pages.

Figure 2. FrontPage "Header" frame layout template

For example, the "Header" frame layout template in FrontPage (Figure 2, above) has the following frame set associated with it:

<FRAMESET rows="64,*">
  <FRAME name="header" scrolling="no" target="main">
  <FRAME name="main">
</FRAMESET>

This frame set gives the top frame the name "header" and the bottom frame the name "main." You can target any hyperlink to any frame by supplying its name. This means the linked page will be shown in the designated frame rather than replacing the entire window. For example, when you create a Hyperlink object or a bound Hyperlink object in Access, you can set the Target property in the hyperlink's property sheet, as shown in Figure 3.

Figure 3. Setting Target properties for the Hyperlink object in Access

If you're creating regular hyperlinks in FrontPage, you can use the Target frame option in the Create Hyperlink dialog box to specify which frame the linked page should appear in. Using this option will result in HTML code similar to this:

<A href="products.html" target="main">Show Products</A>

**Tip   **For flexibility, you should always use relative paths in hyperlinks rather than absolute links. Relative links work the same way on a Web server as they do on your local machine.

Using Server Filters with Frame Sets

Server filters are particularly effective in frame sets. You can have links in one frame that show data access pages in a second frame. The server filter may be supplied as a search parameter that is included in the URL. For example, the server filters in the following three hyperlinks show lists of products that fall into one of three categories: they need to be reordered, they are out of stock, or they are on backorder:

<P><A href="products.html?stock<reorderlevel"
target="main">Low Stock Products</A></P>

<P><A href="products.html?stock=0"
target="main">Out of Stock Products</A></P>

<P><A href="products.html?backordered>0"
target="main">Backordered Products</A></P>

Using server filters can make your Web site appear larger and more dynamic without your having to create a lot of extra pages.

You can also generate server filters programmatically. For example, if you want to do a search based on a form value, as in Figure 4, you can't do the search with a static hyperlink.

Figure 4. Search based on a form value

For this kind of situation, you'll need to use a button (in this case, the Go button) that explicitly loads the page. The following HTML and Microsoft Visual Basic® Scripting Edition (VBScript) code does just that:

<FONT face="Arial Black" size="2">View Products:</FONT><BR>
<INPUT type="text" name="SearchText" size="20">
<INPUT border="0" src="go.gif" type="image" name=GoButton>

<SCRIPT for=GoButton event=onclick language=vbscript>
url = "products.html?serverFilter=""" & _
   "products LIKE '%" & SearchText.value & "%'"""
parent.main.navigate url
</SCRIPT>

Using Server Filters on Intranets or Local Pages

Passing search parameters in a URL works only when pages are hosted on a Web server. If your site is being deployed on a file server over a corporate intranet, or if you want the site to work locally, you can't supply server filters as part of the URL. Instead, you'll need to create the server filter programmatically and apply it as the page is loaded. Note also that when the server filter is supplied as part of the URL, it's visible to users. If you want to hide the details of your server filter, you'll need to create and apply it programmatically.

There's one catch: If the script that applies the server filter is in the page that is being replaced, the script won't be executed because the page will be closed before it can run. The solution is to add common filter-management routines to your navigation frame, because that frame will always be present. Any script that is set up to use a server filter when navigating to a page simply calls these filter-management routines.

The following is the code for the routines that manage the server filters in the navigation frame.

<SCRIPT language=vbscript>
' _________________________________________________________
' Variables and Initialization

Dim numTrackedPages
Dim pages(20)
Dim filters(20)

numTrackedPages = 0

' _________________________________________________________
' Navigation and Filtering

' The following routines keep track of a server filter
' for any pages that have been visited. This allows the user to
' return to the page and have the previous server filter
' stay in effect.

Sub SaveFilterForPage(url, serverfilter)
    For i = 0 to numTrackedPages - 1
        If (pages(i) = Right(url, len(pages(i)))) Then
            filters(i) = serverfilter
            Exit Sub
        End If
    Next

    pages(numTrackedPages) = url
    filters(numTrackedPages) = serverfilter

    numTrackedPages = numTrackedPages + 1
End Sub

Sub NavWithFilter(frame, url, serverfilter)
    SaveFilterForPage url, serverfilter
    frame.location.href = url
End Sub

Function SavedFilter(url)
    For i = 0 to numTrackedPages - 1
        If (pages(i) = Right(url, len(pages(i)))) Then
            SavedFilter = filters(i)
            Exit Function
        End If
    Next

    SavedFilter = ""
End Function
</SCRIPT>

The previous code keeps track of the server filters for up to 20 pages and handles the navigation, but doesn't set the server filter. To do that, you have to add the following script to the bottom of every Web page.

<SCRIPT language=vbscript>
' This script is used in conjunction with NavWithFilter
' to set the server filter for the current page
' after a navigation.
If (window.location.protocol <> "accdp:") Then
    sf = parent.navFrame.SavedFilter(window.location.href)
    If (sf <> "") Then
        On Error Resume Next
        n = MSODSC.RecordSetDefs.count-1
        MSODSC.RecordSetDefs.item(n).ServerFilter = sf
    End If
End If
</SCRIPT>

If you use the previous code in a lot of pages, you should put it in a separate file and use the src attribute of the SCRIPT element to point to the file instead of duplicating it, as shown in the following example:

<SCRIPT language=vbscript src=SetFilter.vb></SCRIPT>

Now, whenever you want to show a page with a server filter, you can do it with a single line of code, like this:

url = "products.htm"
sf = "ProductName LIKE '%green%'"
parent.navFrame.NavWithFilter self, url, sf

For more information about programming data access pages, see Programming Data Access Pages.

Applying Themes

Both Access and FrontPage support Microsoft Office themes, but FrontPage themes have more features. FrontPage also allows you to customize the styles that make up a theme. You can use either Access or FrontPage themes on your data access page, but you shouldn't use both products to apply a theme to the same page.

Posting and Updating Your Web Site

From either Access or FrontPage, you can post Web pages by saving them directly to an http: path or by using Microsoft Office Web Folders. FrontPage also provides additional options for posting your entire Web site.

Once you have posted your Web site, you can directly edit and save pages on your site, as long as your server (1) supports http-put or http-post and (2) is either a FrontPage server or an Office Web server.

**Tip   **To avoid disrupting visitors to your Web site while you're making changes, you should make changes to a "mirror" copy of the site, either on a local hard disk or on an alternative location on your Web server.

Next Steps

For more information about working with data access pages, see Deploying Data Access Pages on the Internet or Your Intranet, Programming Data Access Pages, Creating Secure Data Access Pages, and Connecting Data Access Pages Together.

For more information about working with Web sites, see the Microsoft Web site at www.microsoft.com/ms.htm. In addition to a great deal of information about HTML and DHTML (including new behaviors available in Internet Explorer 5), you'll find information about creating and managing Web sites, including dealing with issues such as deployment and security. Below is a sampling of white papers available on the Microsoft Web site. To find them, click Search and paste (or type) the exact name of the paper.

  • "Web Services Deployment Roadmap"
  • "Developing and Deploying Web Applications"
  • "Understanding Internet Information Server Security"
  • "Internet Information Server Authentication Methods"

You can find additional papers by searching for topics or products you're interested in (for example, "managing Web content" or "Site Server").

Finally, don't forget to consult your Web site and database administrators and the many books about creating Web sites available in your local bookstore.