A
Alan Z. Scharf
Hi,
1. I have a treview that is displaying text values in the child nodes.
2. The child nodees are linked to the parent items by a key code, equivalent
to a CustomerID. In my code below, this code is called 'FundCode'.
3. When achild node is clicked, is there a way to capture the key code value
used to link parent and child, instead of the displayed text of the selected
node?
4. I need the actual key code value to link to a subform on the same main
form as the treeview.
5. My goal is equivalent to getting the hidden value column of a combo box,
reather than the displayed text of the combo.
The treeview code I'm using is below.
Thanks very much.
Alan
Treeview Code
----------------
Private Sub cmdTreeView_Click()
' Purpose: To populate treeview of mutual fund families and their member
funds
'Declare recordset
' ----------------
Dim cnn As ADODB.Connection, rst As ADODB.Recordset, strOrderKey As
String, strProductID As String
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
' Open a recordset and loop through it to fill the Treeview Control
' =================================================================
' Fill Level 1 using ReportPackage as Key property
' -------------------------------------------------
strSQL = ("SELECT ReportPackage FROM dbo.tblReportPackageNames")
rst.Open strSQL, cnn, adOpenForwardOnly
Do Until rst.EOF
Me!treePermalFunds.Nodes.Add , , rst!ReportPackage,
rst!ReportPackage
rst.MoveNext
Loop
rst.Close
' Fill Level 2 using FundCode as Key property
' ---------------------------------------------
strSQL = ("SELECT ReportPackage, FundCode, FundName FROM
dbo.qryReportPackageFunds")
rst.Open strSQL, cnn, adOpenForwardOnly
Do Until rst.EOF
' Link to level 1 by referencing the ReportPackage key and set
' the Node as a child node of Level 1.
' ------------------------------------
strFundCodeKey = rst!FundCode
Me!treePermalFunds.Nodes.Add rst!ReportPackage.Value, tvwChild,
strFundCodeKey, rst!FundName
rst.MoveNext
Loop
rst.Close
' Finish
' -------
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub
1. I have a treview that is displaying text values in the child nodes.
2. The child nodees are linked to the parent items by a key code, equivalent
to a CustomerID. In my code below, this code is called 'FundCode'.
3. When achild node is clicked, is there a way to capture the key code value
used to link parent and child, instead of the displayed text of the selected
node?
4. I need the actual key code value to link to a subform on the same main
form as the treeview.
5. My goal is equivalent to getting the hidden value column of a combo box,
reather than the displayed text of the combo.
The treeview code I'm using is below.
Thanks very much.
Alan
Treeview Code
----------------
Private Sub cmdTreeView_Click()
' Purpose: To populate treeview of mutual fund families and their member
funds
'Declare recordset
' ----------------
Dim cnn As ADODB.Connection, rst As ADODB.Recordset, strOrderKey As
String, strProductID As String
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
' Open a recordset and loop through it to fill the Treeview Control
' =================================================================
' Fill Level 1 using ReportPackage as Key property
' -------------------------------------------------
strSQL = ("SELECT ReportPackage FROM dbo.tblReportPackageNames")
rst.Open strSQL, cnn, adOpenForwardOnly
Do Until rst.EOF
Me!treePermalFunds.Nodes.Add , , rst!ReportPackage,
rst!ReportPackage
rst.MoveNext
Loop
rst.Close
' Fill Level 2 using FundCode as Key property
' ---------------------------------------------
strSQL = ("SELECT ReportPackage, FundCode, FundName FROM
dbo.qryReportPackageFunds")
rst.Open strSQL, cnn, adOpenForwardOnly
Do Until rst.EOF
' Link to level 1 by referencing the ReportPackage key and set
' the Node as a child node of Level 1.
' ------------------------------------
strFundCodeKey = rst!FundCode
Me!treePermalFunds.Nodes.Add rst!ReportPackage.Value, tvwChild,
strFundCodeKey, rst!FundName
rst.MoveNext
Loop
rst.Close
' Finish
' -------
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub