Data Access Pages: What they are and how to create one
Dynamic content is at the heart of successful presentation of enterprise information on the Internet. Without the ability to present data with user interaction, Internet based commerce will be meaningless. It is possible to create dynamic web pages with data from the enterprise by using several technologies, including MS Access.
Using MS Access, it is possible to create dynamic web pages using a couple of techniques. The technology of Active Server Pages; Data Access Pages [DAP] which had their debut in Access 2000; and a combination of IIS, ODBC and the Internet Database Connector can all be used for creating dynamic web pages using MS Access. However, each of these methods have their own ambit in which they are created. ASP, being a server side technology, leverages ADO, while Data Access Pages, a client side technology, depends on DynamicHTML. It is DHTML data binding with ADO that makes Data Access Pages possible. IDC is of historical value only, being version 1.0 of dynamic web page generation technique. Whether or not DAP also becomes of historical value compared to the flagship ASP (ASP.NET) remains to be seen.
Microsoft Access stores all information about the data in its MDB file. However, DAP information is stored in an HTM file with a .htm extension. Since DHTML is behind this technology, it goes without saying that Microsoft's DOM (Document Object Model), the XML, the CSS and related technologies are brought into its creation.
The objective for this tutorial is quite simple. It shows how to create a Data Access Page from scratch and review some of its behavior when displayed on a browser. Data Access Pages being of Microsoft breed may not fare well on other browsers, such as Netscape, FireFox, and Opera. We will check it out during this tutorial. We will be looking at DAP creation from a query, and also converting forms and reports to DAP.
Open a new MDB file, DAP.mdb and bring in some data by importing from the Northwind database as shown. The Customers, Order details, Orders and Products tables were imported into this test setup as shown. The left side of the main page shows all the objects that are available. Presently you have only the tables you imported.
We first created a query, qryBostonCrabMeat, and then generated from it a form frmBostonCrabMeat, and a report rptBostonCrabMeat as shown in the next three pictures. It is assumed that the reader has reviewed previous MS Access articles on this site so that how to create these objects is completely understood.
There are three options, as there are for the other objects in MS Access. You can create a new one; open an existing one; or open the designer to create one. You also have the fourth option to edit an existing one. Let's create a new one. Click on New at the top of the main window.
This wakes up a wizard to create a new Data Access Page as shown. There are again four methods for creating a Data Access Page. The easiest is the AutoPage option. The Page wizard allows you to select, order and group the data. The Design View goes into more details of the page design using field selection and placement on the DAP surface.
Clicking OK after choosing the Page Wizard and selecting the query created earlier opens up the next wizard, the Page Wizard as shown. In this interface you can choose the fields you want to appear in the DAP. Here three out of four available fields from the Query: qryBostonCrabMeat have been chosen.
Clicking Next to the above brings up this window where you can order the columns either in ascending or descending order. Here some choices have been made as shown.
Clicking Next brings up the window wherein you need to choose a unique table from among the several tables related to each other in the query. Here the Orders table was chosen.
Clicking next brings up the final page of the wizard as shown, where you give a name to the Page. You may add certain other features like choosing to modify or not, adding a theme or not, and so forth. Here defaults are used.
.
Clicking Next to the above brings up this DAP GUI designer where you could make changes to the formatting of the page. A title may also be added at this point as shown.
In addition to the above and along side you would also get a list of database objects, also known as Field List as shown. It shows all the database related objects, tables and queries on the database. You could expand a table and look at the columns and their properties, You could drag and drop fields onto the design pane of the GUI. These details are not considered in the present tutorial.
Now click on the top right of the DAP designer and close the window. The next message asking to save the page shows up.
If you click yes to this you will open up the directory where it is going to be saved, C:/ My Documents by default. This is an absolute path reference. Therefore the following message shows up asking you if this is OK.
If you close the above window, the DAP gets created as shown.
Now double click the DAP icon in the above screen and you would see the DAP display as seen in a browser.
The same can be seen by opening the file saved in C:\My Documents as shown here,
Both Netscape 7.0 and FireFox (ver. 1.05) does not show the page but alerts that an IE 5.0 download is needed. Both show, however, the non-data related item, the title.
You could review some of the properties of the DAP by looking at the properties. This is achieved by right clicking an empty area on the DAP page and clicking on properties. You can open the page in design mode by highlighting this DAP and clicking Design in the main menu. This opens up both the GUI as well as the Field List shown earlier. This is shown in the next montage. You can access field list, page properties, group level properties, and element properties. You can also make changes to page color and Font adjustments.
Clicking on Page Properties, and clicking on the connection string ellipsis button in the Data tab therein reveals the following picture. The connection can even be tested here. The data provider is the Microsoft Jet 4.0 OleDB. You could design both the interface as well as the fields that are chosen. The DAP design page has a structure to it. The pop-up properties are context dependent, and you should exercise caution.
This is RAD at its most efficient. For both objects the procedure is the same. Right click the object, and in the dialog that follows, choose to save the object as a Data Access Page. Then choose a location to save the page as well; you can change the name. The following two screen shots are for the form and report created earlier. Both of them saved to the default location, C:\ My Documents. No other details are needed. By saving them to a virtual folder, they can be hosted on the intranet.
Summary
Creating DAP in MS Access is very easy. The tutorial outlines how this is done. Once a query is correctly set up, the creation of DAP follows lines similar to the creation of other table/query based objects, namely Forms and Reports. These pages may be hosted on a web server for Internet access, otherwise, if they are tied to local folders, they will be unavailable on the intranet or Internet as the case may be. For network access the connection string needs to be edited to direct to a relative path. Changes made to the underlying data get reflected in the DAP.