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.
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).
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.
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.
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).
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.
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).
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.
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.
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.
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.
18.225.255.187