Chapter 13. Using Data Access Pages

When data access pages (DAPs) were introduced in Access 2000, they drew a lot of attention from Access developers who were looking for easy ways to move their data to the Web. DAPs promised to provide an Access-based designer that would allow developers to create web pages based on data, just as forms and reports were. Unfortunately, because of the limitations of the DAP design tools, the often-crippled functionality of the resulting pages (such as the inability to update data), and the requirement that users of the pages must have Office 2000 licenses, DAPs were not widely used.

In Access 2002, DAPs have been greatly enhanced. The designer is now on par with Access’s form and report designers. Data on pages can be updated under most circumstances, and users without Office XP licenses can legally work with DAPs in the browser, albeit with a limited feature set. However, you’ll still need to use Microsoft Internet Explorer 5+ to view and work with DAPs, and users will still need to have the Office Web Components installed locally.

Perhaps the biggest limitation to DAPs is the way they connect to data. DAPs use ADO recordsets behind the scenes to retrieve and update data. These ADO recordsets are opened on your users’ machines, which means that your users must have direct access to the data. The only workaround—using recordsets that are opened on a web server—requires that you set up a complicated technology called Remote Data Services (RDS), which goes beyond the scope of this book. Without RDS, you can’t use DAPs to work with data over the Internet, even though you can view the data in a browser.

Still, the Access 2002 implementation has made DAPs a feasible and welcome choice for displaying and editing data, particularly on an intranet (because of the IE5+ and local processing requirements). Database developers may also find that DAPs provide a good starting point in acquiring web database skills.

DAPs are quite different from Access forms and reports. In this chapter, we’ll address issues that you are likely to encounter as you begin to use DAPs. Many of these issues involve getting the page to look the way you want it to look. We’ll also talk about how you can keep your pages and data properly linked together, and we’ll show you how you can use VBScript to add new functionality to your pages.

Tip

DAPs in Access 2002 are very different from DAPs in Access 2000. Not only did Microsoft greatly enhance the functionality of pages designed in Access, but the designer itself also includes many more features. Therefore, we have not addressed the Access 2000 version of DAPs in this chapter.

Replace Navigation Button Images with Your Own Images

Problem

The navigation section in a DAP uses button images that are different from the rest of the pages on your intranet. How can you use your own images on the navigation buttons of a DAP?

Solution

The image on a navigation button is named in the button’s Src property. By default, the Src property for each navigation button is set to an image stored within the Office Web Component library. You can change the property’s value to name an image of your own choosing. You can (and should) also provide an “inactive” version of the image that can be displayed when the button is not relevant to the current context. For example, the First and Previous navigation buttons should be disabled when the user is viewing the first record. The code to change the image based on context has already been written for you; you need only supply an image in the same location and with the same name as the active version of the button, but with the string “Inactive” appended to the name. That is, you might have one image named MyFirstButton.gif and another named MyFirstButtonInactive.gif.

To add your own images to the navigation buttons on a DAP, follow these steps:

  1. Create the images you want to use for the navigation buttons. The Previous and Next buttons for our sample page are shown in Figure 13-1.

    Active and inactive versions of the Previous and Next buttons

    Figure 13-1. Active and inactive versions of the Previous and Next buttons

  2. Create a DAP and add whatever controls you’d like. Once you’ve added fields from tables or queries, you’ll see a default navigation section like the one shown in Figure 13-2.

    The default navigation section includes several buttons

    Figure 13-2. The default navigation section includes several buttons

  3. Eliminate any buttons you don’t want. For our simple example, we eliminated all buttons except the Previous and Next buttons. To get rid of a button, either select it and press the Delete key, or right-click the navigation control, select Navigation Buttons from the context menu, and toggle off the buttons you don’t want.

  4. Select a navigation button and display its properties sheet.

  5. Find the Src property (in the Other page of the properties sheet). Change the property’s value to the name of the image you want displayed, as shown in Figure 13-3. Note that the properties sheet seems to insist on storing the full path to the image, even when it is entered as a relative path.

    Specify the image you want displayed in the Src property

    Figure 13-3. Specify the image you want displayed in the Src property

  6. Repeat Step 5 for each button you need to change.

  7. Test the resulting page. Our sample page looks like Figure 13-4.

    The look of our page is now consistent with the rest of our intranet

    Figure 13-4. The look of our page is now consistent with the rest of our intranet

Discussion

All the functionality for a navigation button is contained within the DataSourceControl Office Web Component. The name of the image to use, though, is stored in the HTML source of the page. The component itself checks for the name with the “Inactive” string to adjust the appearance of the button relative to the context.

The properties sheet appears to store a full path to the image. That is, you might type in the following text:

ImagesArrowLeft.tif

But when you leave the property, the value will be adjusted to show a full path and filename:

c:MyPagesImagesArrowLeft.tif

Internally, however, the HTML source is storing a relative path. If the path to the page changes but it retains an Images subfolder, the page will not break; the image in the relative path will still be found. (The same can’t necessarily be said of your data, of course.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.252.201