If have created the following code the populate a treeview control:
Private Sub Form_Load()
Dim db As Database
Dim rst As Recordset
Dim rstchild As Recordset
Dim objnode As Object
Dim strKey As String
Dim strparent As String
Set db = CurrentDb
Set rst = db.OpenRecordset("tblDept"
With rst
.MoveFirst
If .RecordCount Then
Do Until .EOF
strKey = ![DeptID] & "L1"
Set objnode = trvwTest.Nodes.Add(Key:=strKey, _
Text:=![DeptID])
objnode.Sorted = True
.MoveNext
Loop
End If
.Close
End With
Set rstchild = db.OpenRecordset("tblEmployees"
With rstchild
.MoveFirst
If .RecordCount Then
Do Until .EOF
strKey = ![EmployId] & "L2"
strparent = ![DeptID] & "L1"
Set objnode = trvwTest.Nodes.Add(relative:=strparent, _
relationship:=tvwChild, Key:=strKey, _
Text:=![Name])
.MoveNext
Loop
End If
.Close
End With
db.Close
Set rstchild = Nothing
Set rst = Nothing
Set db = Nothing
End Sub
Private Sub trvwtest_NodeClick(ByVal Node As Object)
Me.Text1.Value = Node.Text
Me.Text2.Value = Need Treeview Level Number Here
End Sub
Everything works great, but I need the level number of the treeview to move to the text2 textbox.
any help is greatly appreciated....many hours spent,,,,NO LUCK!!!!!!!!!!
Private Sub Form_Load()
Dim db As Database
Dim rst As Recordset
Dim rstchild As Recordset
Dim objnode As Object
Dim strKey As String
Dim strparent As String
Set db = CurrentDb
Set rst = db.OpenRecordset("tblDept"
With rst
.MoveFirst
If .RecordCount Then
Do Until .EOF
strKey = ![DeptID] & "L1"
Set objnode = trvwTest.Nodes.Add(Key:=strKey, _
Text:=![DeptID])
objnode.Sorted = True
.MoveNext
Loop
End If
.Close
End With
Set rstchild = db.OpenRecordset("tblEmployees"
With rstchild
.MoveFirst
If .RecordCount Then
Do Until .EOF
strKey = ![EmployId] & "L2"
strparent = ![DeptID] & "L1"
Set objnode = trvwTest.Nodes.Add(relative:=strparent, _
relationship:=tvwChild, Key:=strKey, _
Text:=![Name])
.MoveNext
Loop
End If
.Close
End With
db.Close
Set rstchild = Nothing
Set rst = Nothing
Set db = Nothing
End Sub
Private Sub trvwtest_NodeClick(ByVal Node As Object)
Me.Text1.Value = Node.Text
Me.Text2.Value = Need Treeview Level Number Here
End Sub
Everything works great, but I need the level number of the treeview to move to the text2 textbox.
any help is greatly appreciated....many hours spent,,,,NO LUCK!!!!!!!!!!