Write scripts for data source controls in the data access page

zhaozj2021-02-11  198

Write scripts for data source controls in the data access page

Mark Robertsmicrosoft Corporation 2001 Abstract: To write scripts for data access pages, you must learn about the data access page and the underlying object model of the dynamic HTML page, Microsoft Office Data Source control, and Microsoft Data Access The interaction of the Microsoft Data Access Components. This article focuses on the following objects in the Data Source Control Object model: section, GroupLevel, DataPage, and ElementExtension. These objects determine the layout, structure, and data binding of the data access page. This article explores how these objects integrate with DHTML objects so that they can work with page itself and use ADO objects to work with data to be bind to pages. In addition, this article also summarizes the following:

How to write a script data access page architecture for the "Microsoft Office Data Source" control in the data access page, integrated with functional HTML pages, data source control, and Microsoft data access components, you will also see To a summary, all new methods and properties, these methods and attributes have been added to the data source control object model for Access 2002. Directory Introduction What is a data source control? Make the data access page Object Model Fixed Data Source Control Object Section Object GROUPLEVEL Object DataPage Object ElementEXTENSION Object Data Source Control Event Access 2002 Data Access page Is new features? Additional Information Introduction Data Access Page Design to reproduce Microsoft® Access Forms and Reports on a web page running on Microsoft Internet Explorer 5.0 or later. In addition to simply reproduce forms and reports, the data access page provides more features and benefits, especially for data browsing, data entry, reporting, and analysis from a web browser. You need access 2000 or higher when you create a data access page, but users with data access page requires only Internet Explorer 5.0 or higher, installing Microsoft Office Web components, and in the case of real-time data, you need there Sufficient secure license for the data source connected to the page. The data access page is based on a variety of technologies and components. The most important is the "Microsoft Office" control (MSODSC), and the part of the set, editing, and analyzing the data is called Microsoft Office Web Components. The "Data Source" control integrates the function of dynamic HTML (DHTML) object model and ActiveX data object (ADO); the former is implemented by Microsoft HTML analysis and reproduction engine (MSHTML), and the latter is to Microsoft Data Access Components ( MDAC) program interface. Figure 1: Data Access Page Components This article focuses on the various core features of the "Data Source" control and the relationship between the DHTML and ADO object models, and how to use these knowledge, extend and customize the data access page by writing scripts. Most of this information stated herein can be used to access the data access page created in Access 2000 and Access 2002. It also describes some of the new features provided in the Access 2002 data access page. Data Access Page in Access 2002 "Design View" has a number of improvements, such as multi-level revocation, multi-selected page elements, improved attribute browsing, a dragging area for grouping, and the "Typical Wizard" list "Drag the multiple fields or display the entire table), so that the layout of multiple fields is easy. To get the best design experience, you should create a data access page in Access 2002 in the case of Internet Explorer 5.5 or higher ("Design View" to improve the INTERNET Explorer 5.5 or higher. Several components installed in the version). Note: The data access page created in Access 2002 cannot be turned on in "Design View" in Access 2000. Similarly, once you open the data access page created in Access 2000 in the "Design View" of Access 2002, you cannot reopen it in Access 2000. However, if the user is equipped with a Microsoft Office XP web component, the page created in Access 2002 can be opened in the "Design View" of Access 2000.

This article does not use the "Data Source" control for Microsoft Office Chart, Spreadsheet, and PivotTable® components. For more information on these components, see the Microsoft Office 2000 / Visual Basic Programmers (English) using Office Web Components (English) and a variety of Microsoft Office 2000 Web Components (English) books (published by Microsoft) Society publishing). What is a data source control? The main function of the "Data Source" control is to connect to the data source, establish and execute commands for these data sources, and retrieve the results of these commands and the elements that are bound to the page. In addition, the "Data Source" control also tracks the records that the user is currently operating. For more complex pages with "stripes", "Data Source" also creates a hierarchical grouping. For example, you can display a order form with a sub-form that is displayed from an order detail from a related table, or a sales report that is packet data in multiple layers, such as in accordance with the month, region, and sales. Nested groups of representatives. (For more details on striped pages, see the layout of the data access page later in this article). Unlike Office Web Components Controls, the "Data Source" control is an ActiveX® control that does not have any visible interfaces at runtime. When you create a new data access page in Access, a tag is inserted into the head element in the data access page to define the "Data Source" control. The tag for the data access page is always set to MSODSC for the Id attribute of the tag for the data access page. If you open a data access page in the Microsoft Script Editor of Access 2002 (by opening the data access page in Design View, then click Microsoft Script Editor "on the Toolbar), you can page The upper part is seen for the tag for the "Data Source" control. Behind the ClassID attribute of the control is a wide range of XML definitions for the various properties of the control, such as the Connectionstring property and the ElementExtensions collection. The ElementExtensions set is used to add custom properties to data binding HTML elements in the data access page, and only exist after being binded to a page. A more detailed description of the ELEMENTEXTENSIONS collection is partially described later. IMPORTANT: Do not modify the tag for the "Data Source" control directly in the HTML of the data access page. You should modify these settings from the "Design View" in Access in Access, or modify the various methods and properties of the "Data Source" control object model. Make the object model behind the data access page, which is meaningless to the Office Web component Chart, SpreadSheet, and PivotTable controls. The function of the data access page is not included in a separate ActiveX control (although the data access page is the same as all the web pages, CHART can be , Spreadsheet and PivotTable controls are combined together). At the most basic level, the data access page contains the interaction of a "Data Source" control with a set of DIV elements, while the latter is used as a label, control, and data binding elements of the page. Extension of the functionality of the data access page, you might need to use the DHTML document object model, and the Data Source Control Object Model. There are two main reasons:

The main elements that make up a typical data access page are inherent HTML controls and data binding span elements. The interaction of the user and page is usually referring to an event that occurs in the context of the HTML document. Because the "data source" control is designed to integrate with the HTML element, its object model contains some members (HTMLContainer attributes such as section object), which are used to write scripts to access various collection, attributes, and methods of the DHTML document object model. . This allows you to use a variety of HTML elements that make up the data access page. In addition to interacting with each part of the DHTML Document Object Model and integrating it, the "Data Source" control is also encapsulated by the ADO function, and is used to operate the record set through the page. Since the record set may be a hierarchical structure, it may contain a column containing the calculated results generated at runtime (also known as "shaping record set"), the packaged ADO function is collaborated with OLE DB MSDataShape Provider, and OLE DB CURSOR ENGINE The actual data provider of the data source itself cooperates. "Data Source" control is designed to manage most of the use details of these data access components, and the "Data Source" control object model also contains members that allow you to access ADO objects; for example, the connection of DataSourceControl objects The property is used to access the ADO Connection object of the page data source, and the DataPage object's RecordSet property enables you to access a group of specific records displayed in a page. Data Source Controls "Data Source" control shows a variety of sets and objects, but you need to know the main objects you need to know when using the data access page: section object GROUplevel object DataPage object Elementextension objects can be set from the corresponding DataSourceControl object collection Access GroupLevel, DataPage, and ElementExtension objects, but do not have a collection corresponding to the section object. This is because Internet Explorer reproduces the actual section at runtime. The "Data Source" control target model is provided with a set of Section objects, and a set of properties and objects are provided for accessing a particular section on the page (described later in this article). The following sections describe how these objects map to the data access page, and the relationship with the typical data access page custom task. The basic part of the data access page Basic part of the data access page may be a bit confusing in the Design View, so they understand how their meaning and how these parts are mapped to the "Data Source" control object model. Relevant collections and objects. This is very important. As the data access page uses a hierarchical group, its underlying structure changes. There are two basic types of data access pages:

Simple page - these pages displays a single record field, without any repetitive logging or hierarchy grouping. Although simple pages do not have any grouping, in terms of the underlying data model, it does have a separate group level (GroupLevels.count = 1) and a set of properties associated with the group level. For example, the "Employee" "Employee" of the Russend Business sample database is a simple page. With striped pages - these pages are displayed in a stripe format each time you display multiple records, and these stripes are repeated from top to top. With striped pages or no hierarchical packets (substantially a simple page, its single set of DataPagesize property is greater than 1), or may also display a hierarchical structure of associated or packet records. By default, the band stripping page only shows the first layer of the hierarchical structure, and the lower packet level is folded below the expand control ( icon). For example, the "Ross Wen Business" sample database "Review Order" page is a striped page with a hierarchical packet. For more information on profiling by profile, please refer to the GroupLevel object later. The design of the data access page can be composed of up to four sections: Title - Title is the first section of the simple page, or the first section of a group level in a strip page, the most typical situation is for Displayed in the following header sections display column header. However, the title may contain any type of control other than data binding controls. When you create a data access page in Design View, you don't have a title feature by default. To add a title feature, right-click the page eyebrow section, then click Title. Header - Although this section is called eyebrows, it is functionally similar to the form of forms or reports. The header is mainly used to display the data and calculated values ​​in the data binding control. The simple page has a single header festival, each showing a record, and stripping pages show multiple records each time, and repeat the header festival for each record. A striped page with multiple grouping levels contains nested header festivals for each packet level. Footer - Footer Section is associated with the header feeding at the same packet level. The page feet is often used to display a total or small meter for data displayed in the relevant header festival, but you can also add the bind to the controls of the fields and other controls. You do not default to the footer section when you create a data access page in Design View. To add a footer section, right-click on the page, then click Foot. You cannot add footparts to simple pages or strippages with a single page. On the page with a packet (page with two or more header), the footer will not be added to the lowest (most innermost) level in the packet structure. Record browsing - The record browsing section is a simple page or the last section of the group level in the stripping page, associated with the header feeding on the same packet level. It contains a record browsing control, which is used to move between records, or add, delete, save, revoke changes, or filtering records in records. Record the browsing section shall not contain the data binding control. The Section object is designed to see section as a two-dimensional container for layout each control and element of your data access page. When you start creating a data access page in the Design View, Access adds a separate section that does not have any specific types of ties to the unbinding section. The first section was originally unbound because the "Data Source" control of the page did not have any available RECORDSET objects in its RecordSets at the beginning of the design process. There are two ways to be used to bind data to the section:

Drag fields or tables from the Field List to the section in the section, the RecordSource attribute in the feature list will be bound by one of the two methods, making the section a header and automatically add a new page. The browsing section is related to the brow. Both binding mechanisms automatically add the RecordSet object to the RecordSets collection of the "Data Source" control associated with the page. These fields can be used for binding controls by setting the ControlSource property of the field defined by the field defined by the generated RecordSet object to the desired field. If you drag and drop the field or table from the Field List, Access sets the same name as the binding field (or generates a unique name), and sets the control of the controlsource properties of the control. This is bound to it. If you are binding the section by setting the RecordSource property and then adding the control from the Toolbox to a section, you must manually specify the ControlSource property for the control. Tip: You can view the structure of the data bound to the page (called "Data Model") by displaying the Data Outline. To display the Data Outline, open the data access page in Design View; point to "Toolbar" on the View menu, then click Data Outline. You can view and set up the properties of each item that makes up the data model, such as GroupingDef, PageField, PageRowsource, and RecordSet objects, right-click an item in the outline, and then click Properties. IMPORTANT: Access When binding a section to the data, set the ID attribute of the

tag to reflect the table bound by the section. You must change the ID attribute in the Microsoft Script Editor because this may interfere with the data binding function of the page. Also, if other fields are added to the section in the Design View, the Access may change the ID attribute of the section. Therefore, you should first complete the basic design of the page before you add a script to the data access page. Otherwise, you must update all