Type | Description | |||
Column as Variant | A long expression / string expression that specifies the column where the value is being requested. | |||
Variant | A safe array with all values of selected / active items in the view, on the specified column. |
As Microsoft Access uses DAO, you need to use the View's DataSource property rather than control's DataSource property as in the following sample:
Private Sub CascadeTree1_CreateView(ByVal View As Object) With View Select Case .Index Case 1: ' State or City .DataSource = CurrentDb.OpenRecordset("Select * FROM States WHERE CountryCode IN (" & .ParentView.ValueList("CountryCode") & " )") .Tag = "State" .Key = "StateCode" .Name = "StateName" If (.Items.ItemCount = 0) Then .DataSource = CurrentDb.OpenRecordset("Select * FROM Cities WHERE CountryCode IN (" & .ParentView.ValueList("CountryCode") & " )") .Tag = "City" .Key = "" .Name = "Name" .ColumnAutoResize = False End If Case 2: ' City .DataSource = CurrentDb.OpenRecordset("Select * FROM Cities WHERE CountryCode IN (" & .ParentView.ParentView.ValueList("CountryCode") & ") AND StateCode IN (" & .ParentView.ValueList("StateCode") & ")") .Tag = "City" .Key = "" .Name = "Name" End Select End With End Sub Private Sub Form_Load() With CascadeTree1.DefaultView .DataSource = CurrentDb.OpenRecordset("SELECT * FROM Countries") .Tag = "Country" .Key = "CountryCode" .Name = "CountryName" End With End Sub
The sample loads the Countries table into the default view ( view with the index 0 ). Once the user clicks / selects / activates an item, the control creates a new view ( with the index 1, 2 and so on ) and fires the CreateView event. During the CreateView event you can load data from different tables based on the parent's view selection. See the ParentView.ValueList