WHY DATA ACCESS PAGES?

One of the first questions asked when developers look at DAPs is, “Why do I need to use Data Access Pages when I have forms and reports, which I am so comfortable with?” That is a very good question, and one that this chapter should answer for you.

Understanding How Data Access Pages Are Structured

Data Access Pages are primarily separate HTML files with a shortcut in the Access database window. When not using the simple page version, which is a single record displayed and edited at a time, Data Access Pages are built based on the “banded” theory, in which each “band” has grouping and sorting. This said, DAPs are neither forms nor reports, but a hybrid of the two, mixed with HTML features.

You can see an example of grouping by looking at a simple example of a DAP in Northwind.mdb (see Figure 12.1).

Figure 12.1. This Data Access Page, Review Products, is located in the sample database Northwind.mdb.


You can tell which sections can be included for each group, including a Caption section, Header section, Footer section (not shown in Figure 12.1), and Navigation section.

As with reports, you specify grouping by using the Sorting and Grouping dialog (see Figure 12.2). Unlike reports, even your most basic DAP (using data) will include one record source grouping on a page. You can open this dialog by clicking on the Sorting and Grouping toolbar button on the Data Access Page Design toolbar.

Figure 12.2. This dialog looks very similar to the Sorting and Grouping dialog, but is quite different.


Note

In the preceding paragraph, I used the phrase using data because you can create static pages that are simply like any other Web page. This might be for creating a home page that doesn't require any data.

However, you never, ever want to do this because even that kind of page will attempt to make a connection to a database. If it can't find the database, your users will get annoying dialog boxes. You should use Word or FrontPage in that scenario.


Table 12.1 lists some properties you can set for each record source.

Table 12.1. Group Properties for the Sorting and Grouping Dialog
Property Description
Caption Section This property displays a Caption section for the group. This is displayed when the group above the current group is expanded. You can't bind any controls in this section. This is closest to the Report Header section of a report.
Group Header This property displays a Header section for the group. Actually, this section is closest to the form/report's detail section.
Group Footer This property displays a Footer section for the group. As with the Header section, this works primarily as it does with reports, for displaying footer information and summarizing data, if desired.
Record Navigation Section As it says, this displays the record's navigation control for the group. It will show after the Footer section, if there is one; otherwise, it will show in the Header section. The Data Page Size property affects the number of records displayed at a time, on the page and in this control. You can place other controls in the navigation section—they just can't be bound. However, putting unbound controls there is frequently useful. For example, you can replace the barely customizable—and rather slow-performing—Navigation control with your own navigation buttons.
Expanded By Default This affects whether to expand the lower group level items by default.
Data Page Size This property specifies how many items at a time you want display for the group. If you want all records displayed, set this property to All.
Group On Field that you want to group on.
Group Interval Number of characters or interval of specific data type to group on.
Default Sort Which field in the group to sort on by default.
Group Filter Control You want to use this combo box or listbox control to filter the group's records on.
Group Filter Field This is the field that's used to compare against the Group Filter Control to filter the records in the group on.

Tip

You will get better performance when viewing the page by setting all levels of the page's Expanded By Default property to No.


Tip

The smaller the Data Page Size value is set, the faster those records will be displayed. Only use All when you know you have a limited number of records in the data page.


Note

If you're using the page for editing records, you can include only one group on the page. The Data Page Size property is then set to 1. You can see an example of this by looking at the View Products DAP in Northwind.mdb (see Figure 12.3).

Figure 12.3. When editing records, you can display one at a time on a page.


Any action you take that causes this number to become greater than 1 (for example, adding grouping or banding or manually changing it) will cause your page to cease to be updateable.


Understanding the Navigation Control

In addition to the ActiveX controls and bound HTML controls, one major control is the Navigation control. This control looks similar to the navigation buttons found on the standard form, but contains a few more features in the additional commands it can contain (see Table 12.2).

Table 12.2. Properties to Use on the Navigation Control
Property Description
ShowDelButton Deletes a record
ShowFilterBySelectionButton Filters for records that match the selected field
ShowFirstButton Moves to the first record
ShowHelpButton Displays Help
ShowLabel Displays the information specified in the RecordsetLabel property
ShowLastButton Moves to the last record
ShowNewButton Moves to a new record
ShowNextButton Moves to the next record
ShowPrevButton Moves to the previous record
ShowSaveButton Saves the current record
ShowSortAscendingButton Sorts records in ascending order
ShowSortDescendingButton Sorts records in descending order
ShowToggleFilterButton Applies or removes a filter
ShowUndoButton Undoes the last record

Tip

For the most professional-looking pages, you should hide any buttons that don't apply to your page. For example, if you have a nonupdateable page (see the previous note), hide the Delete, Save, Undo, and New buttons. Access will not do this for you.


The other property of the Navigation control to discuss is RecordsetLabel, which is a string value. In Figure 12.3, the RecordsetLabel property for the Products group level is set to "Products |0 of |2;Products |0-|1 of |2" (default). Here is how the string breaks down:

  • The first string (before the semicolon), which reads "Products |0 of |2", is the mask for what's shown when a single record is displayed on the page.

  • The second string (after the semicolon) represents the label that's displayed when two or more records are displayed on the page.

  • |0 shows the current record number on a page used for data entry or the number of the first visible record in the group on a grouped page.

  • |1 shows the number of the last visible record in the group on a grouped page.

  • |2 shows the number of records in the recordset.

Note

You might be wondering why I'm going into such detail about the Navigation control so early in the chapter. Getting a handle on this control and the Sorting and Grouping dialog was key to helping me understand and get a handle on creating Data Access Pages.


Let's take a step back and look at how DAPs fit with standard Access reports and forms. That way, you can get some more ideas about how to really take advantage of DAPs.

Comparing Data Access Pages to Forms and Reports

Traditional Access forms and reports are separated into two purposes: data input (forms) and presentation (reports). Data Access Pages can be used for either purpose. I have even heard DAPs referred to as “interactive reports.”

The following can be accomplished with DAPs and their form or report counterpart, and a description of what the task is.

Task Counterpart
Analyzing information Form for parameters, and then calls report
Inputting data Form
Making projections Form for parameters, and then calls report
Reviewing data Form for parameters, and then calls report

Note

Although the lines can blend when it comes to defining which object is used for handling one task or another, these items are the generally accepted choices for solutions.


Another big difference between DAPs and the other two objects is that DAPs aren't stored in the Access database. They are HTML files to which Access creates a shortcut in the Pages tab of the database window. You can see the DAPs (with the extension of .htm) in Chap12.mdb listed in the Explorer in Figure 12.4. The folder on the CD-ROM this is located in is ExamplesChap12.

Figure 12.4. The *.htm files with corresponding to the names used for the DAPs in Chap12.mdb can be incorporated directly into a Web page.


Because the connection information is stored with the DAP, using it with Access and the Web is pretty easy.

Note

The biggest issue is what happens when you move the data source containing mdb/adp. None of your pages know how to connect anymore. Hence, the ugly FixDataAccessPageLinks routine found in the StartUp module in Northwind.mdb.


Understanding What Users Need for Data Access Pages

For users to take advantage of DAPs with live data outside Access 2000 (using an intranet or the Internet), they need to have Internet Explorer 5.0 or higher and a Microsoft Office 2000 license.

This generally makes the DAPs useful for either just displaying data on an intranet—because you can't rely on the whole world having a Office 2000 license (although Microsoft wouldn't mind)—or on your company's intranet, providing you have a site license for Office 2000.

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

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