Microsoft Office 2000 Developer |
If you want to take advantage of the hierarchical features of the Hierarchical FlexGrid control on an Access form, you must create a data source that returns a hierarchical cursor. This can be done most easily by compiling the Data Environment designer as a DLL file. The DLL then becomes the data source.
Note The control does work properly with a standard recordset, it just does not use any of the hierarchical features of the grid.
It's also possible to create a hierarchical cursor by setting the RecordSource of an ADO Data Control or the Source property of an ADO Recordset object to a Shape command. See Shape Commands in General for an introduction.
Note Because the Hierarchical FlexGrid cannot be bound at design time to a data source, the Retrieve Structure command will fail.
To display a Hierarchical FlexGrid control on an Access form
For information about setting up a Data Environment as a data source, see Inserting ActiveX Designers into a Visual Basic Editor Project.
For information on compiling the DataEnvironment object, see Creating a DataEnvironment Object for Use in a DLL File.
Option Compare Database
Option Explicit
' Assuming the name of the DLL is prjDE, and the name of the
' DataEnvironment object is deNwind.
Private myDE As deNwind.DataEnvironment1
Private Sub Command1_Click()
Set myDE = New deNwind.DataEnvironment1
Dim myGrid As MSHFlexGrid
Set myGrid = myFlexGrid.Object
' The DataEnvironment object compiled in the DLL has a function
' named ThisRS. It takes one argument, the name of the table
' desired, and returns the recordset.
Set myGrid.DataSource = myDE.ReturnRS("Customers")
End Sub