I have a treeview control on one of my access forms. The first part of the code that I use to populate the control is working fine. However, the second part, or the child portion, isn't populating like it should. It actually acts more like a parent. I can't see what's wrong - maybe I've stared at it too long? I would really appreciate any help!
Code:
Dim strQuery1 As String
Dim strQuery2 As String
Dim rst As ADODB.Recordset
Dim strNode1Text As String
Dim strNode2Text As String
Dim strVisibleText As String
Dim nod As Object
Set rst = New ADODB.Recordset
strQuery1 = "spTreeviewDAyOfSaleParcels"
strQuery2 = "spTreeViewDayOfSaleParcelINFO"
Dim cnn As New ADODB.Connection
Set cnn = Application.CurrentProject.Connection
With Me.tvParcels
'Fill Level 1
rst.Open strQuery1, cnn, adOpenKeyset, adLockOptimistic
Do Until rst.EOF
strNode1Text = StrConv("Level1" & CStr(rst!id), _
vbLowerCase)
Set nod = .nodes.Add(Key:=strNode1Text, _
Text:=rst!parcel)
nod.Expanded = True
rst.MoveNext
Loop
rst.Close
'Fill Level 2
rst.Open strQuery2, cnn, adOpenKeyset, adLockOptimistic
Do Until rst.EOF
strNode1Text = StrConv("Level1" & CStr(rst![id]), vbLowerCase)
strNode2Text = StrConv("Level2" & CStr(rst![id]) & Nz(rst![INFO], "") & Nz(rst![ItemNO], ""), vbLowerCase)
strVisibleText2 = Nz(rst![INFO], "")
.nodes.Add relative:=strNode1Text, relationship:=tvwChild, Key:=strNode2Text, Text:=strVisibleText
rst.MoveNext
Loop
rst.Close
End With