You can create data access pages in one of the following four ways:
Using AutoPage
Using a wizard
From an existing Web page
From scratch
To create a data access page using AutoPage, follow these steps:
Click Pages in the list of objects in the Database window.
Click the New button in the Database window. The New Data Access Page dialog box appears.
Choose the table or query on which you want to base the data access page.
Select AutoPage: Columnar from the list of options for creating a data access page (see Figure 26.9).
Click OK. Access creates the data access page (see Figure 26.10).
To create a data access page using a wizard, follow these steps:
Click Pages in the list of objects in the Database window.
Double-click the Create Data Access Page By Using Wizard option. The Page Wizard appears.
Select the table or query on which you want to base the data access page. In Figure 26.11, the Employees table is selected.
Select the fields that you want to appear on the data access page. In Figure 26.11, the EmployeeID, FirstName, LastName, Title, BirthDate, HireDate, HomePhone, and Extension fields are selected. Click Next to continue.
Add any desired grouping levels to the page (see Figure 26.12). In Access 2000, the created page was rendered not editable when grouping was applied. Fortunately, this is no longer the case in Access 2002 and Access 2003! Click Next to continue.
Select a sort order for the records included on the page (see Figure 26.13). In the figure, the page is sorted by the LastName field combined with the FirstName field. Click Next to continue.
The last page of the wizard asks you for a title for the page. You can also opt to apply a theme to the page. Enter the title, select whether you want to apply a theme, and then designate whether you want to open the page or modify the page's design. Click Finish to complete the process. If you clicked the check box to apply a theme to the page, the Theme dialog box appears (see Figure 26.14). Select a theme and click OK. Figure 26.15 shows the completed page in Design view. Figure 26.16 shows the completed page in Page view.
Access does
not store data access pages in your database file or project. Instead, Access saves data access pages as HTML files. To save a data access page, follow these steps:
Click Save on the toolbar. The Save as Data Access Page dialog box appears (see Figure 26.17).
Enter the name of the HTML document. In the figure, the name is entered as pagEmployee. Click Save.
A dialog box appears, suggesting that the connection string should point to a UNC path. Doing so ensures that the data behind the page is available over the network.
Although Access saves the data access page as a separate document, it appears in the Database window (see Figure 26.18). Notice in the figure that a ToolTip appears, indicating the name and location of the saved HTML document. When you open the data access page from within Microsoft Access, it appears as a window within the Access environment. To view the page as it will appear in a browser, right-click the page in the Database window and select Web Page Preview.
You might already have an HTML document that you have created. Fortunately, Access 2002 and Access 2003 allow you to base a new data access page on an existing HTML document. To create a data access page from an existing Web page, follow these steps:
Click Pages in the list of objects in the Database window.
Double-click the Edit Web Page That Already Exists wizard option. The Locate Web Page dialog box appears (see Figure 26.19).
Select an existing HTML document and click Open. You can now edit the page right within the Microsoft Access environment.
Although the Data Access Page Wizard is very powerful, there are times when you will want to build a data access page from scratch. You would do this, for example, when the page you were creating was either very simple, or in no way resembled the output from the Page wizard. To create a page from scratch, follow these steps:
Click Pages in the list of objects in the Database window.
Double-click the Create Data Access Page In Design View option. You receive the warning shown in Figure 26.20. If you create a data access page in Access 2003, you will not be able to open it in Design view in Access 2000 or Access 2002. If you have installed the Microsoft Office 2003 Web Components, you can open the page in Page view in Access 2000 and Access 2002.
Click OK. A blank data access page appears (see Figure 26.21).
Add controls to the data access page and set their properties.
You might wonder how to associate a table from your database with a data access page that you build from scratch. The process differs somewhat from the process of associating a form with data. The process is as follows:
Click the Field List tool on the toolbar. The Field List window appears (see Figure 26.22).
Notice that the Field List window shows two expandable lists: one with the tables in the database, and the other with the queries in the database (see Figure 26.23).
To add all fields from an existing table or query to the data access page, drag an entire table or query from the field list to the data access page.
To add specific fields from a table or query to the data access page, expand the field list to display the desired table or query, and then drag and drop individual fields to the data access page. In Figure 26.24, selected fields have been added from the Employees table to the data access page.
NOTE
Because data access pages are stored as separate HTML documents, Access will not be able to locate the data access pages associated with a database if the pages are deployed to a different directory structure than the structure that existed when they were first created. You must write code to "fix" the links to the pages. The Northwind.MDB database that ships with Access 2003 contains sample code that you can use in your applications to fix these broken associations.