I have two tables:
tblClassification - id, classification
tblSnipplets - id, classification, title, dateadded, code
I have the key for the treeview classification because I can't use id for some reason. I am having problems when I click on the node I want view the info in some text fields. I think I have the key messed up. Any help would be greatly appreciated.
Thanks
Code:Private Sub initializeTree() tvwItems.ImageList = imgList Dim nodClass As Node Dim nodTitle As Node tvwItems.LineStyle = tvwRootLines tvwItems.Nodes.Clear 'Initialize the recordsets Set rsClass = New ADODB.Recordset Set rsTitle = New ADODB.Recordset 'Open the Class recordset strSQLClass = "SELECT id, classification FROM tblClassification ORDER BY classification" rsClass.Open strSQLClass, conTree, adOpenStatic, adLockOptimistic 'set node for treeview If rsClass.RecordCount > 0 Then While Not rsClass.EOF Set nodClass = tvwItems.Nodes.Add(, , (rsClass.Fields("classification")), (rsClass.Fields("classification")), 1) 'Opens the recordset for Title strSQLTitle = "SELECT id, title, classification, code, dateadded FROM tblSnipplets WHERE classification LIKE '" & (rsClass.Fields("classification")) & "%'" rsTitle.Open strSQLTitle, conTree, adOpenStatic, adLockOptimistic 'set node for treeview If rsTitle.RecordCount > 0 Then While Not rsTitle.EOF Set nodTitle = tvwItems.Nodes.Add((rsClass.Fields("classification")), tvwChild, (rsTitle.Fields("title")), (rsTitle.Fields("title")), 2) rsTitle.MoveNext DoEvents Wend End If rsTitle.Close rsClass.MoveNext DoEvents Wend End If End Sub Private Sub tvwItems_NodeClick(ByVal Node As MSComctlLib.Node) strNodeLabel = Node If Node.Image = 2 Then strSQLTitle = "SELECT * FROM tblSnipplets WHERE classification = '" & Me.tvwItems.SelectedItem.Key & "'" Set rsTitle = New ADODB.Recordset rsTitle.Open strSQLTitle, conTree, adOpenStatic, adLockOptimistic showData Set rsTitle = Nothing End If End Sub




Reply With Quote