Northwind.mdb includes a few sample .htm files to demonstrate simple DAP design techniques. With Northwind.mdb open, click the Database window's Pages shortcut to display the list of sample pages. Double-click the page name in the Database window's list to open a page in Page view. Page view uses IE 5+'s XML parser and HTML engine to display the page in a window similar to that for displaying conventional Access forms. The Page View menu substitutes for the Form View menu when you open a DAP. Tip Clients require IE 5.5+ to take advantage of some of the features of Access 2003 DAP, such as multiselecting controls in Page Design view. For maximum security, IE 6+ is recommended for all DAP clients. Users can download the latest version of IE from the Internet Explorer page (http://www.microsoft.com/windows/ie/). Version 6.0 SP1 was current when this book was written. The Review Products PageThe majority of DAP that you design probably will be read-only pages for displaying summary data, detail data, or both. Northwind.mdb's simplest read-only sample page is Review Products, shown in Page view in Figure 24.4, which displays records of the Products table grouped by the first letter of the product name. The black arrows for expanding and collapsing individual bands called section siblings are one of six symbols that you can choose in the properties window for the Expand/Collapse object (MsoExpandCollapse, which is one of OWC 11's ActiveX controls). Figure 24.4. The Review Products page is an expandable list of products grouped alphabetically by the ProductName field of the Products table. Black arrows replace the standard Access expand/collapse icons (boxes with +/ symbols).
Figure 24.5. The Review Products page opened in IE 6.0+ is identical to Access's Page view. Page view uses IE's rendering engine (often called Trident, its beta name) to execute the DHTML code that generates the page. When you click Expand All, VBScript code changes the button's caption to Collapse All.
Choose View, Source in IE to open Notepad with a copy of the DHTML and XML code, and turn on Word Wrap (see Figure 24.6). The five xmlns:... lines in the <HTML... tag define Office XML namespaces used by DAP; xmlns:dt... is the namespace for standard field data types. Code in the <OBJECT tag specifies the id of the Data Source Control as MSODSC and the Globally Unique Identifier (GUID) of the control in the Registry as its ClassID value. Attribute/value pairs in the <a:ConnectionString> element fully define the Jet OLE DB provider's connection to the Northwind.mdb database. The content of the <a:ConnectionString>...</a:ConnectionString> element is identical to that of an .odc file for a local connection to Northwind.mdb. As mentioned earlier in the chapter, the connection string displays the User ID (the default is Admin for Jet) and, if the database is secure, the user Password or Database Password in clear text. Figure 24.6. The <HEAD> section of the DHTML code for DAP sets up the Data Source Control (MSODC) to connect to the specified Jet or SQL Server database. The highlighted <OBJECT... line is the start of the XML code to establish the database connection.
Note Escaped characters in the XML code make reading the connection string difficult. 
 represents carriage-return/line-feed pairs for formatting; "" represents empty double-quotes ("", "" in HTML). It's clear from the complexity of the XML source code shown in Figure 24.6 that few, if any, Access users or developers will attempt to edit the XML elements in Notepad or any other HTML editor. The page designer automatically generates the underlying XML and HTML source code when you open a new page, and it alters the code as you add or modify objects in Page Design view. When you edit or move an object, the DAP Designer alters the HTML code within the division (<DIV>...</DIV>) that contains the object. (<DIV> elements are near the end of the file.) DAP use CSS to fix the relative position of each visible object on the page. The position reference point is the upper-left corner of the section in which the object appears. VBScript for the onclick event of the page's two command buttons appears immediately below the end (</STYLE>) of the CSS style definitions for standard page objects, including a Navigation control that's not present on this page. Clicking the cmdRefresh button applies the Requery method to the first and only data page (DataPages.Item(0)) of the Data Source Control. The second VBScript block expands or contracts the section siblings, depending on their state, which is stored in the caption (innerText property) of the cmdExpandCollapse button (see Figure 24.7). Figure 24.7. This VBScript code expands or collapses all sections of the Review Products page. The state of the page is maintained by the value of the innerText property of the cmdExpandCollapse button.
Page Design ViewAs mentioned early in the chapter, Page Design view differs dramatically from Form Design view. To explore the new and upgraded features of the page designer, do this:
The Page Design ToolbarThe Page Design view toolbar has many buttons in common with the Form Design view toolbar. The most welcome addition for Access 2000 page designers are the added Undo and Redo buttons, which have a drop-down list that lets you undo or redo multiple changes. Table 24.1 describes the Page Design toolbar buttons that don't have a counterpart in the Form Design toolbar. Table 24.1 also includes a menu choice that isn't present in Form Design view. Single-menu commands identified by an asterisk (*) are choices of the form's context menu.
The Page ToolboxThe Page Toolbox has 24 buttons; 12 of the buttons correspond to those of the Form/Report Toolbox. The Label, Text Box, Option Group, Check Box, Drop-down List, List Box, Image, Line, and Rectangle buttons generate the DHTML version of native Access controls. The Select Objects, Control Wizards, and More Controls buttons perform identical functions to the corresponding button in the Form/Report Toolbox. Table 24.2 describes the Toolbox buttons specific to DAP.
The process of adding Toolbox controls to the page is the same as that for forms and reports. You also can drag table, query, or field nodes from the Field List to the section to create bound objects. When you drag a table or query node to the section, the Layout Wizard dialog opens to enable selection of the page layout or the OWC control to display the data. Field List ButtonsThe Field List has the three buttons described in Table 24.3.
The Microsoft Script EditorUnlike IE, which uses Notepad to display HTML source code, the designer uses the Microsoft Script Editor (formerly HTML Source Editor) derived from that of Visual Studio 6.0. Clicking the Microsoft Script Editor button or choosing View, HTML Source opens the Script Editor, if you installed it during the Office 2003 setup process. Otherwise, a message box appears that asks if you want to install it. The Script Editor defaults to a color-coded HTML source window with docked Document Outline and Project Explorer windows (see Figure 24.9). The Project Explorer refers only to the currently active page, so close it to expand the area of the source window. Figure 24.9. All HTML-enabled Office 2003 applications use the Microsoft Script Editor, which is shown here with Word Wrap off and the Document Outline and Project Explorer windows open.
Many of the features of the Script Editor don't apply to DAP, so most of the default toolbar buttons are disabled. The Script Editor has its own Toolbox, which is useful only for creating HTML pages from scratch. Online help topics for the Script Editor aren't very useful for working with DAP, but the HTML Reference Help and VBScript Help topics provide a wealth of information on the DHTML object model and scripting. Most of the help topics are links to pages on the Microsoft Developer Network (MSDN) Web Workshop site. Caution Don't make any changes in the Script Editor to the code created by the page designer. For DAP, the Script Editor is intended for adding or editing VBScript or JScript Microsoft's implementation of ECMAScript only. If you change the page designer code, your page is likely to display errors or fail to open in Page or Page Design view. If you make an accidental change to page-designer code, close the Script Editor and don't save the changes. The following is a list of three of the Script Editor features that are useful when working with DAP:
Figure 24.10 shows the Script Editor in Script Only view with an event-handling stub for the MSODSC control's Current event and the Object Member list for the MSODSC object. The MSODSC.Current event corresponds to the On Current event of a bound Access form. Figure 24.10. The Script Editor page is configured to display the document outline with the MSODSC control node expanded to display the control's event repertoire. The control's events duplicate those for a bound Access form and have additional events that apply only to pages.
|