It is bombing on the child node. I need a second set of eyes because I have looked at it and I can't see anything that is wrong.
Thanks.
Code:'Declarations for treeview Dim strKeyCat1 As String Dim strTextCat1 As String Dim ndCat1 As Node Dim strKeyCat2 As String Dim strTextCat2 As String Dim ndCat2 As Node 'Initalize imagelist TreeView1.ImageList = imgList TreeView1.LineStyle = tvwRootLines TreeView1.Indentation = 25 'Declarations for Data Connection & Recordsets Dim rstCat1 As New ADODB.Recordset Dim strSQLCat1 As String Dim rstCat2 As New ADODB.Recordset Dim strSQLCat2 As String 'Open data connection dbconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\code.mdb;User Id=admin;Password=" 'set sql string for parent node strSQLCat1 = "SELECT cat1 FROM tblCat1 ORDER BY Cat1" 'open rst for parent node rstCat1.Open strSQLCat1, dbconn, adUseClient, adLockReadOnly 'clears the tree nodes Me.TreeView1.Nodes.Clear While Not rstCat1.EOF strKeyCat1 = UniqueKey strTextCat1 = rstCat1("cat1") Set ndCat1 = TreeView1.Nodes.Add(, , strKeyCat1, strTextCat1, 1) ndCat1.Tag = strKeyCat1 'set sql string for child node strSQLCat2 = "SELECT Cat2, cat1 FROM tblCat2 " & _ "WHERE cat1 = '" & rstCat1("cat1") & "' " & _ "ORDER BY Cat2" 'open rst for child node rstCat2.Open strSQLCat2, dbconn, adUseClient, adLockReadOnly ' If rstCat2.RecordCount > 0 Then While Not rstCat2.EOF strKeyCat2 = UniqueKey strTextCat2 = rstCat2("cat2") Set ndCat2 = TreeView1.Nodes.Add((rstCat1.Fields("cat1")), tvwChild, strKeyCat2, strTextCat2) <--- Element Not Found ndCat2.Tag = strKeyCat2 rstCat2.MoveNext Wend rstCat2.Close rstCat1.MoveNext ' End If Wend rstCat1.Close Set dbconn = Nothing End Sub




Reply With Quote