3 4
Data access pages give you the means of publishing pages on the Web that work with data in Access or SQL Server databases. Data access pages were first introduced in Access 2000, but they weren’t very easy to use. Access 2002 provides many enhancements that make it much easier to create and modify data access pages. In this section, we’ll look briefly at each of these enhancements.
See Chapter 18, "Working with Data Access Pages," for more details on the changes to data access pages.
When you create a new data access page (or open an existing data access page in Design view), you’ll find a host of improvements and new features, including the following:
Data access page properties are now easier to use because of better organization of the properties sheet and several new builders that help you select the appropriate value for a property. You’ll find the following enhancements:
Access 2002 includes several new features that make it easier to deploy your data access pages on the Web after you’ve designed them, as follows:
note
There are a few other miscellaneous changes related to data access pages that make them easier to work with, including a Data Access Page selection in the Save As dialog box for forms, some features that allow you to link to XML documents, and a number of Data Source control attributes.
You can prepare a data access page for offline work by setting a number of page properties, all available through the object model, or by opening the data access page in Internet Explorer and selecting Make Available Offline in the Add Favorite dialog box. For details on working with data access pages off line, see Chapter 18, "Working with Data Access Pages."
You can now save forms and reports as data access pages by selecting Data Access Page in the Save As dialog box, as shown in Figure 1-15. Saving a form as a data access page saves a lot of time when you want the page to look just like an existing form. You don’t have to design the data access page from scratch; instead, you can create it from a form you’ve already created.
Figure 1-15. You can save a form as a data access page and save the time it takes to design the page from scratch.
You can create an XML document or XML data island (XML data embedded in HTML code) from a data access page by using the ExportXML method.
You can set the properties described in Table 1-4 either on the page’s properties sheet or through code at runtime.
Table 1-4. XML data binding properties
Property | Value | Description |
XMLLocation | dscXMLDataEmbedded | Data appears on the page as a data island. |
| dscXMLDataFile | Data is an XML data document. |
XMLDataTarget | dscXMLDataEmbedded | Sets the ID of the data island. |
| dscXMLDataFile | Sets the UNC, URL, or absolute path and name of the XML document. |
UseXMLData | True | Connection to the live source is dropped and the data access page is bound to the XML source. |
You can now bind data access pages to any arbitrary recordset. Use the SetRootRecordset method to bind to disconnected and persisted recordsets.
The Data Source control is used behind the scenes to bind data access pages to a data source. Unlike other controls, it has no representation in the interface; you program it in VBA code. This control now has several new events that give you more places to respond to user actions.
Table 1-5 lists the new Data Source control events.
Table 1-5. New Data Source control events
Event | Description |
AfterDelete | Occurs after a record deletion has been confirmed and the record has actually been deleted, or after the deletion is canceled |
AfterInsert | Occurs after a new record is added to the recordset |
AfterUpdate | Occurs after a record is updated with changed data or after the record loses focus |
BeforeDelete | Occurs before the record is actually deleted |
BeforeInsert | Occurs when the first character is entered into a new record, but before the record is actually added to the recordset |
Before | Update Occurs before a record is updated with changed data or before the record loses focus |
Dirty | Occurs when the contents of a record change, and before the BeforeUpdate event |
Focus | Page-level event that occurs when a section receives the focus (as opposed to the Current event, a recordset-level event that occurs when the record changes in the underlying recordset) |
RecordExit | Occurs after all update events have fired and before the record loses currency |
Table 1-6 lists the new Data Source control constants. These constants are used to set the Data Source control properties or are returned by its events, enabling you to take different actions in code depending on what choice a user makes in the interface.
Table 1-6. New Data Source control constants
Constant | Description |
dscDeleteOK | Indicates that delete operation succeeded |
dscDeleteCancel | Indicates that delete operation was canceled through code |
dscDeleteUserCancel | Indicates that delete operation was canceled by the user |
dscDisplayAlertContinue | Determines whether a custom error message or no error message is displayed |
dscDataAlertDisplay | Indicates that standard error dialog box should be displayed |
dscRefreshData | Causes the Refresh method to refresh the data cache while maintaining the current connection |
The new EuroConvert function converts a number to euros or from euros to another currency. You can also use this function to convert a number from one currency to another by using the euro as an intermediate value.
Banded data access pages are now updatable, and child recordsets are fully updatable, enabling you to add, modify, and delete records from the child recordsets assigned to each band of data.
The Group Level properties sheet allows you to control whether the child recordsets are updatable by setting the following properties:
These properties are set to False by default for converted DAPs. DAPs created in the interface have these properties set to True.