Article ID: 162523 - View products that this article applies to.
This article was previously published under Q162523
Advanced: Requires expert coding, interoperability, and multiuser skills.
The Data Outline control is not included with the Microsoft Office 97 Developer Edition (ODE) as it is in the Microsoft Access Developer's Toolkit versions 2.0 and 7.0. The TreeView control enables you to display a hierarchical list of items, and you can use it in your Microsoft Access 97 database as a replacement for the Data Outline control.
This article discusses some differences you may encounter when you use the TreeView control in place of the Data Outline control. It covers the following topics:
162359This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.
(https://support.microsoft.com/kb/162359/EN-US/ )ACC97: Access 97 Data Outline ActiveX Control Available in Download Center
Both the TreeView control and the Data Outline control can display hierarchical data. However, the ways in which you populate the controls with data are quite different. For example, many features of the Data Outline control that you set in its property sheet must be set with Visual Basic code in the TreeView control.
A key element in the TreeView control is the Node object in the Nodes collection. You use the Nodes collection to create hierarchical levels in the TreeView control.
How to Fill Levels with Data in the TreeView ControlYou must use Visual Basic code to fill a level in the TreeView control with data. In most cases, you open a RecordSet object and loop through the records to create Nodes in the TreeView control. The following example populates a TreeView control with a list of Customers in the Northwind sample database.
How to Link Nodes in the TreeView ControlEach level in the Data Outline control has a LinkMasterFields property that enables you to link each level in the form to the level above it. In the TreeView control, you use the Key property of the Node object to link one node to another.
You can set the Key property when you use the Add method of the Nodes collection to add a level to the TreeView control. Then you reference that key when you add new nodes to the TreeView control, and that is how different levels are linked together. Following are some important tips about using the Key property:
How to Associate a TreeView Node with a Form in Your DatabaseEach level in the Data Outline control has a FormName property that you can set to associate a particular form with a level in the control. In the TreeView control, you can use the NodeClick event to reference the currently selected node, and then use the Key property of the node in the OpenForm method's Where condition to open a form to the correct record. For example:
You can also add the same functionality to a button on your form, as the following example illustrates.
The following example builds on the form you created in the previous sections. It uses the length of the Key value for the selected node to determine whether to open the Customers, Orders, or Products form.
This method is faster than clearing and refilling the entire TreeView control when only one record has changed.
Also, if a user can change a field that you are using in the Key property of a node in your TreeView control, you must update that Key property. You only have to update the parent node, and the change is automatically propagated to all child nodes:
Distributing the TreeView Control with a Run-time ApplicationThe TreeView control is contained in the Comctl32.ocx file, which Microsoft Office 97 Developer Edition (ODE) sets up in your Windows System folder. You must include this file when you redistribute an application that contains the TreeView control.
When you include Comctl32.ocx in the List Of Files box in the Setup Wizard, the Wizard searches for that file's dependency file, Comctl32.dep. The dependency file tells the Setup Wizard what other support files need to be included with the ActiveX control. If you have Comctl32.dep on your hard drive, you will notice that the Setup Wizard automatically includes Comcat.dll in the List Of Files box when you add Comctl32.ocx; Comcat.dll is a required support file for Comctl32.ocx. If the Setup Wizard cannot locate the Comctl32.dep file, you must manually add Comcat.dll to the list of files you redistribute with your application.
Differences in Event Models Between TreeView and Data Outline ControlsThe Data Outline and TreeView controls each support different event models. As a result, you may have to rewrite portions of your code when you migrate from the Data Outline control to the TreeView control. The following table compares the events in the two controls and identifies where no corresponding event is available.
Data Outline Control Event TreeView Control Event --------------------------------------------------- AfterCollapse Collapse AfterExpand Expand AfterFormClose <none> AfterFormOpen <none> AfterFormUpdate <none> AfterMove <none> AfterRefresh <none> AfterRequery <none> AfterSelChange NodeClick AfterStartup <none> DoKeyPress KeyPress DoRowClick <none> (Closest events are Click and MouseDown) DoRowDblClick <none> (Closest event is DblClick) Enter Enter ErrorEvent <none> Exit Exit FailCollapse <none> FailExpand <none> FailFormOpen <none> FailFormUpdate <none> FailMove <none> FailSelChange <none> GotFocus GotFocus KeyDown KeyDown KeyUp KeyUp LostFocus LostFocus MouseDblDown <none> (Closest event is DblClick) MouseDown MouseDown MouseUp MouseUp RequestCollapse <none> (Closest event is Collapse) RequestExpand <none> (Closest event is Expand) RequestFormOpen <none> RequestFormUpdate <none> RequestHelp <none> RequestMove <none> RequestSelChange <none> Updated Updated <none> AfterLabelEdit <none> BeforeLabelEdit <none> MouseMove <none> OLECompleteDrag <none> OLEDragDrop <none> OLEDragOver <none> OLEGiveFeedback <none> OLESetData <none> OLEStartDrag
TreeView Control PerformanceFilling TreeView nodes from an array is faster than filling them from a Recordset object. However, it is common to use the TreeView control to display data from a table or a query, so Recordset objects are used frequently. You can improve the speed with which your TreeView fills with data by using the DbOpenForwardOnly argument of the OpenRecordset method, as shown in the examples in this article.
If you open and loop through Recordset objects to fill TreeView nodes with data, it may take some time to open a form or to display TreeView control data when you are working with large recordsets. In contrast, the Data Outline control automatically binded to your data, which made it faster to see data from large tables or queries.
Limitations of the TreeView Control vs. the Data Outline ControlThe Data Outline control and the TreeView control are very different from one another in many respects. Because the TreeView control can display hierarchical data, it is the best choice among the ODE controls to replace your Data Outline control; however, there are some features of the Data Outline control that the TreeView control cannot emulate. For example:
For more information about using the TreeView control in Microsoft Access 97, search the Help Index for "TreeView control."
Article ID: 162523 - Last Review: January 19, 2007 - Revision: 3.3
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.