Getting Acquainted with Page and Page Design Views

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 Page

graphics/data_access_using_wizard.gif The 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).

graphics/24fig04.gif

graphics/access_2002_new_icon.gif

With the page in normal (not maximized) view, right-click the page's title bar, choose Web Page Preview to open Review Products.htm in IE. Click the Expand All button to execute VBScript code that expands each section sibling to display a list of all Northwind products (see Figure 24.5). The expanded page emulates a conventional Access report that users can print. Pages designed for viewing in a browser, however, aren't optimized for printing. The Review Products page has an excessive amount of vertical whitespace between sibling sections and product data. If you want to generate a page for printing, the better approach is to design an Access report and save it as a page. Chapter 25, "Converting Access Objects to Data Access Pages," explains how to take advantage of Access 2003's Save as Data Access Page feature.

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.

graphics/24fig05.gif

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.

graphics/24fig06.jpg

Note

Escaped characters in the XML code make reading the connection string difficult. &#13;&#10 represents carriage-return/line-feed pairs for formatting; &quot;&quot; represents empty double-quotes ("", &quot;&quot 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.

graphics/24fig07.gif

Page Design View

As 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:

  1. graphics/data_access_using_wizard.gif graphics/design_view.gif Open Review Products or any other Northwind.mdb sample page in Page Design view.

  2. graphics/field_list.gif Click the Field List button to open the Field List, if it doesn't open by default. The Field List ordinarily docks to the right edge of the designer's window and resembles a task pane (see Figure 24.8). Unlike the task pane, you can undock the Field List.

    Figure 24.8. The Review Products page is open in Page Design view with the page Toolbox, Field List, and Data Outline windows visible.

    graphics/24fig08.jpg

    Note

    The Field List has nodes for every table and query of the source database. Expanding a table node reveals the table's fields; if the table has predefined relationships with other tables, the node has a Related Tables subnode.

  3. graphics/data_outline.gif Click the Data Outline button to open the Data Outline floating window. The Data Outline windows displays the hierarchical structure of the page's sections and control objects.

The Page Design Toolbar

graphics/undo.gif graphics/redo.gif The 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.

Table 24.1. Page Design View Toolbar Buttons and a Menu Command That Aren't Present in Form Design View
 

Name

Menu Command

Description

graphics/e_mail.gif

Email

File, Send To

Sends a copy of the page embedded in the text of a message or as an attachment, or sends a link to the page on a server share.

graphics/promote.gif

Promote

Promote*

Moves the selected section higher in the section hierarchy.

graphics/group_by_table.gif

Group by Table

Group by Table*

Lets you group by the primary key of the table on the one side of a one-to-many relationship. Group by Table works with pages that have two or more related tables or queries with fields from multiple tables.

graphics/demote.gif

Demote

Demote*

Moves the selected section lower in the section hierarchy.

graphics/autocalc.gif

AutoSum

None

Lets you select from SQL aggregate functions to add a control to display the sum, average, minimum, maximum, count, or standard deviation of numeric values within a section or group of sections.

graphics/field_list.gif

Field List

View, Field List

Opens the Field List.

graphics/data_outline.gif

Data Outline

View, Data Outline

Opens the Data Outline windows that display the hierarchical data model of the page.

graphics/ms_script_editor.gif

Microsoft Script Editor

View, HTML Source

Opens the Microsoft Script Editor and displays the DHTML code of the form.

 

None

Format, Theme

Opens the Theme dialog, from which you can select a style sheet from one of the 65 designs installed by Office 2003 setup or available from the distribution CD-ROM.

The Page Toolbox

graphics/toolbox.gif The 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.

Table 24.2. Page Toolbox Buttons That Don't Have a Counterpart in the Form Toolbox
 

Name

Description

graphics/bound_span_control.gif

Bound Span

Adds a <SPAN> element with a label and text box

graphics/scrolling_text.gif

Scrolling Text

Adds a DHTML multiline text box (marquee) to the page

graphics/expand.gif

Expand

Adds an Expand/Collapse button to a section

graphics/record_navigation.gif

Record Navigation

Adds the standard record navigation bar to a section

graphics/pivot table.gif

Office PivotTable

Adds an OWC PivotTable control to the page

graphics/pivot chart.gif

Office Chart

Adds an OWC PivotChart control to the page

graphics/spreatesheet_control.gif

Office Spreadsheet

Adds an OWC Spreadsheet control to the page

graphics/insert_hyperlink.gif

Hyperlink

Opens the Insert Hyperlink dialog to add a file-based or conventional navigational hyperlink

graphics/image_hyperlink.gif

Image Hyperlink

Opens the Insert Picture dialog in which to select a graphic file, followed by the Insert Hyperlink dialog to specify the target page

graphics/movie.gif

Movie

Opens the Insert Video dialog in which you can select an .avi, .mov, .mpg, .mpg, or .asf file to run in a simplified version of the Windows Media Player installed on the client

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 Buttons

The Field List has the three buttons described in Table 24.3.

Table 24.3. Buttons on the Field List Toolbar
 

Name

Description

graphics/page_connection.gif

Page Connection Properties

Opens the Data Link Properties dialog to change database connection settings

graphics/refresh_field_list.gif

Refresh Field List

Queries the database and updates the field list

graphics/add_to_page.gif

Add to Page

Lets you make multiple selections in the Field List and add the objects to the page section in a single operation

The Microsoft Script Editor

graphics/ms_script_editor.gif Unlike 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.

graphics/24fig09.jpg

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:

  • Limit the editor to displaying script by choosing View, Show Script Only, or by clicking the Script Only View button on the editor's toolbar. Script Only view prevents you from making inadvertent changes to page-designer code and speeds up fixing your scripts.

  • Display a Document Outline window by choosing View, Other Windows, Document Outline or by pressing Ctrl+Alt+T. This window has a node for every object in your page; expanding a node displays a list of the events fired by the object. Double-clicking an event item inserts a VBScript event-handler stub for the event.

  • Open an Object Member list by typing the id of an object such as MSODSC and the object separator (a period). The Object Member list displays all properties and methods of the object. Double-clicking a member adds the name at the cursor location.

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.

graphics/24fig10.jpg



Special Edition Using Microsoft Office Access 2003
Special Edition Using Microsoft Office Access 2003
ISBN: 0789729520
EAN: 2147483647
Year: 2005
Pages: 417

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