Getting Started with Forms on Data Access Pages


Data access pages can exhibit behavior similar to traditional Access forms and reports , except that they work across a web. When all clients use Internet Explorer 5 or later and you can install the Office 2003 Web Components on all workstation clients , data access pages offer a quick and easy route to developing forms that work across the Web.

In many ways, building solutions with forms for data access pages is similar to building a solution for forms within Access. This similarity makes data access pages an attractive technology for Access developers who want to begin building Web solutions. Despite the fact that building data access pages is similar to creating forms, data access pages are Web pages. This means that the appropriate browsers can open them just as they would any other Web page. Of course, Access forms and reports do not have this characteristic.

The sample application for this section creates a form on a data access page that displays selected fields from the Products table. Then it creates another form on another data access page that allows users to filter the products that the first data access page shows.

Creating a Product Tracking Form

The sample database file for this chapter, Chapter14.mdb, has links to the Northwind database. Chapter14.mdb is available with the companion content for this chapter. This means you can readily exhibit data from the Products table, which includes inventory information about products. One common way to view data, especially if users might need to update it, is with a form. You can build a data access page that lets Web users browse and update the contents of the Products table.

There are at least two graphical ways you can build a form for the Products table. One relies on a wizard similar to the Form Wizard. You can launch the Page Wizard by selecting Pages on the Objects bar in the Database window and then double-clicking Create Data Access Page By Using Wizard. This way of building pages targets end users and beginning developers. The second approach lets you construct a form in an environment that is similar but not identical to the Design view for Access forms. This approach shows more basic functionality than using the Page Wizard does. This section and much of the remaining discussion about data access pages highlight managing data access pages in Design view.

Begin creating a form on a data access page for the Products table by highlighting Pages in the Objects bar on the Database window and double-clicking Create data access page in Design view. When you get to the Design view, you will see a grid for positioning controls on your form (unless you changed the default setting) as well as a title area above the grid. You can optionally click in the title area and type text for the page's title. Otherwise, the area appears blank. Since our task is to build a form for the Products table, we need to bind the form to this table.

Note  

The visibility of the grid that denotes the area for positioning controls is optional. You can control the visibility of the grid by using the View, Grid command.

The grid area is the area that you bind to a record source for your form. If you click anywhere inside the grid, handle controls appear around the grid to indicate that you've selected it. Display the properties for the grid by clicking the Properties tool on the Design view toolbar. Notice that the grid is a Section object with an assigned name of SectionUnbound; this name changes as you specify the design of your page. Select the Data tab on the Properties dialog box, and observe the RecordSource property setting control. Clicking the down arrow lets you specify any table or row-returning query as a record source for the grid.

After selecting the Products table as a record source, Access divides the original grid into two sections. A navigation control appears in a section below a blank grid. If you select each section and examine their Properties dialog boxes, you will discover that they have section Id settings: HeaderProducts for the top grid area, and NavigationProducts for the control below the grid area. These names appear in the title bar for the Properties dialog box. Captions appear in bars at the top of each similarly named section on the data access page. These bars and captions appear only in Design view. Each section with data has a RecordSource property. The setting for both sections is Recordset: Products. If the Field List isn't already visible from the design session for a previous page, you can click the Field List control on the Page Design toolbar. This click opens a Field list to the right of the data access page with data sources in the connection for the current .mdb or .adp file.

You can add individual controls to the grid to help design a form. There are at least two approaches to this. First, you can open the Toolbox and then position controls from it to the grid to specify a form's layout. This works similarly to the Design view of an Access form, except that some different controls are available. When you take this first approach, you must individually specify a ControlSource property for all bound text box controls that you add. The ControlSource setting binds the text box to a field in the RecordSource property for the section. The second approach is to move items from the Field List to the top area of the grid. One easy way to do this is to successively double-click the fields in the Field List that you want to add to your form. This technique automatically creates bound controls and aligns them in a columnar fashion.

Note  

Before double-clicking fields in the Field List to add them to a data access page, be sure to select the section to which you want to add the fields as controls.

If you click the ProductID , ProductName , UnitsInStock , ReorderLevel , and Discontinued fields, your top section will contain four text boxes and a check box for the Discontinued field. Each bound data control on the form has a matching label control as well. However, the text boxes appear in a default width that is too small for several product names. You can update the Width property of the ProductName text box by selecting it and then dragging its right edge to make it wider. Alternatively, you can type a number followed by a unit of measurement in the Width setting on the Format tab of the Properties dialog box for the ProductName text box. For example, type 2in to designate a width of 2 inches.

There are two possible metrics for specifying the width: inch and pixel. However, pixel is the default. If you type a number without designating a unit of measurement, Access assumes that the number represents the width of the text box in pixels. When you drag the width of the text box, Access converts the setting from its default value of 1 inch to some other width specified in the unit of measurement used before resizing started.

You can resize the other text box controls to match the width of the ProductName text box. However, it's not necessary to manually reset the width for each of the other three text boxes to match that of ProductName. Instead, you can use the Alignment And Sizing toolbar (display the toolbar if it does not already show). Next, select the ProductName text box if it isn't already selected. Then double-click the Size Width control on the Alignment And Sizing toolbar. This double-clic



Programming Microsoft Office Access 2003
Programming MicrosoftВ® Office Access 2003 (Core Reference) (Pro-Developer)
ISBN: 0735619425
EAN: 2147483647
Year: 2006
Pages: 144
Authors: Rick Dobson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net