It's easy to create a Data Access Page in MS access by invoking the wizard. Still, you may want to know how to create a DAP from scratch. This article explains how to do it.
In a previous tutorial, creating Data Access Pages (DAP) in MS Access was described. Importantly, the basic mechanics involved in crafting a DAP were discussed using the easiest of the methods -- invoking the wizard. While the easiest way to create such a page as described earlier fits in with the RAD features, one may need to know how to create a page starting from scratch.
This tutorial will show how to create a DAP using the design option starting from scratch. The demonstrated example is verified on a Windows XP Professional with MS Access 2002, SP1. As discussed in the previous article, the information about data and related information is stored in an .htm file for a DAP as against an .mdb file for data. Since it is in an .htm file, it is Microsoft DOM compliant. I recommend reviewing the first tutorial on DAP.
Since MS Access has undergone changes with the various versions by varying degrees of complexity and enhancements, it is necessary to have elements that work with older versions.
Creating a DAP in Design View
Start a DAP in design view
As with other Microsoft Office products, there is more than one way to create an object -- and so it is with DAP. Either you can use the menu item - Design, the short cut - Create a data access page in design view; or you can click on the menu Item New and follow the wizard. For any of these actions you get the response as shown in the picture. You will see that the page created in this version is not readily reusable in Access version 2000.
Clicking OK to this will bring up the design view of the page as shown. The areas on this page will bring up context sensitive pop-up menus relevant to that area. The title bar of this page, the label marked Click here and type the title text, the tabular region and the blank area will all bring up their related menus when right clicked to access their properties. I changed the title by typing in My First Page as shown.
Configuring the DAP in design view
By right clicking an empty region of the page, or the title bar, the Page1 properties can be accessed as shown here. If you are familiar with MS Access you will see this is a common way to configure an object in design. The three tabs, Format, data, and other provide all the design time information.
Click on the tab Data and in the window that pops up, click on the browse button (...) by the side of Connection File. This brings up the Select Data Source window dialogue as shown here.
This lists all the data source connections in the My Data Sources folder. Since the idea is to start from scratch, click on the button New Source... adjacent to the text box relevant to File Name:. This brings up the next picture as shown.
In this window the Microsoft SQL Server is chosen and the Next> button is clicked (You could also try the other option). This brings up the next window as shown here. The server name is typed in as shown. Here it is XPHTEK, the name of the SQL Server on this machine which can be accessed by using the Windows 2000 security log in for this machine.
On clicking Next>, the following window shows up where you need to choose the source of your data. The drop-down list should show all the databases on your server as shown.
The database pubs is chosen, and when this choice is made all the tables and views in this database are listed in this window as shown.
Clicking on Next> brings up a window that lets you save the connection with some description information, as well as saving some key words for searching at a future date, if needed. Clicking Finish will save the connection information to the My Data Sources folder.
As the connection is completed, it is now possible to get an idea of the fields available for the data access page. The field list can be accessed from the View menu item by choosing the Field List dropdown item as shown
This will populate and bring up the Field List as shown in this picture. The field list shows everything on the chosen database.
From here it is possible to drag and drop the table from the field list to the design pane of the page as shown for the Authors table. If you wish to bring only some of the fields you may highlight the fields you want and drag them in a bunch to the design page. This action brings up the window to craft a layout of the table. For this tutorial, a tabular one is chosen as shown (columnar is the default).
Clicking OK will bring the table columns, with the column headings to the page as shown in a tabular format. To visualize it better, some of the fields have been left out of the picture. If the table occupies a region wider than the default Page1's width, the page width automatically widens to accommodate all the fields. Here you can click on individual items (for example, field captions) and change them to something meaningful, say au_id to Author ID. You may remove items to retain only those you want, and so on. There is a great deal of flexibility in rearranging data in the design view.
At this point you can save the page and take a look at how it would look in a preview, but you will have to save the page. When you use the menu item File -->Save As you will be required to give a name to the page or, take the default - Page1. Assuming that you choose to save as PageDapTest1, it gets saved to the default directory, My Documents. This page1 also gets added to the Pages tab in the Microsoft Access UI as shown.
If you double click the item Page2, we can see how it may appear on a web page as shown here. This display is still within the Access application.
One can go back to the design page and make further changes. This next picture shows how you may change the column name from au_lname to Last name. Clicking on au_lname you can access the element's properties (in this case the label), element being an element in the Microsoft DOM, and change its inner Text property as shown (montage of two windows).
<
Changing a group of elements
You also have the flexibility to apply formatting to a group of elements as it was in earlier versions, for example, if you do make changes and they get somewhat misaligned you can apply alignment to a group of labels as shown.
Accessing the Page properties
If you were to highlight a data field as in the next picture (some formatting has already been changed for this picture after deleting some of the fields and their column names), and look at its properties, you can access the Page, the GroupLevel, Section, and the elements' properties as shown here. You may also incrementally save your design to have a different name so that you may come back later and make further changes.
The options that are available are almost inexhaustible (unless you get exhausted!). For example you could bring in the Microsoft Script Editor to help with some advanced formatting and page design by clicking on Script editor as shown.
Hosting the DAP on the Intranet
It is possible to save the DAP's HTM file to the web server root. When you try to place the file you may get a message as follows:
If you accept the Yes option, your default location for your DAPs will be the root directory of your web server. In this example, the option Yes is taken. Since it is now in a more public location you will receive further warnings, the first of which is, The Website uses a data provider that may be unsafe, if you trust the website, click OK, otherwise click Cancel.:
On accepting this you may get further warnings as to who is accessing this page as follows: This website is using your identity to access a data source. If you trust this website, click OK to continue, otherwise click Cancel.
With this your data access page will be placed on the web server. In this case it was saved with the file name, TestingDap.htm. Now it is accessible by using its URL, http://localhost/TestingDap.htm.
Summary
This tutorial shows how to create a data access page starting from scratch and how to host it on an intranet site. Although data base connectivity is one of the most important aspects, creating a GUI for users is equally important. One of the reasons for Microsoft Access's immense popularity is the flexibility it offers in UI design. The tutorial also treats how to modify the page once it is created, and indicates guidelines for those interested in its advanced features.