By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,963 Members | 1,402 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,963 IT Pros & Developers. It's quick & easy.

Help Converting from Treeview 5 to Treeview 6

P: n/a

I have changed the control in my form to a Treeview 6 instead of 5 and
my code no longer works as before. Can anybody help me here.

There are no errors, but I only end up with the first entry (parent)
showing and nothing happens with my NodeClick events either.

Here is the code to add branches to the tree (taken from somewhere and

Sub AddBranch(rst As DAO.Recordset, strPointerField As String,
strIDField As String, strTextField As String, Optional varReportToID As
On Error GoTo errAddBranch
Dim nodCurrent As Node
Dim objTree As TreeView
Dim strCriteria As String
Dim strText As String
Dim strKey As String
Dim nodParent As Node
Dim bk As String
Set objTree = Me.ActiveXCtl27.Object
'Set objTree = Me.TreeCtrl2.Object - old version 5 object

If IsMissing(varReportToID) Then ' Root Branch.
strCriteria = strPointerField & "=0"
Else ' Search for records pointing to parent.
strCriteria = BuildCriteria(strPointerField,
rst.Fields(strPointerField).Type, "=" & varReportToID)
Set nodParent = objTree.Nodes("a" & varReportToID)
End If

' Find the first emp to report to the boss node.
rst.FindFirst strCriteria

Do Until rst.NoMatch
' Create a string with LastName.
strText = Nz(rst(strTextField), "BLANK")
strKey = "a" & rst(strIDField)
If Not IsMissing(varReportToID) Then 'add new node to the parent
Set nodCurrent = objTree.Nodes.Add(nodParent, tvwChild, strKey,
Else ' Add new node to the root.
Set nodCurrent = objTree.Nodes.Add(, , strKey, strText)
End If

' Save your place in the recordset so we can pass by ref for speed.
bk = rst.Bookmark
' Add employees who report to this node.
AddBranch rst, strPointerField, strIDField, strTextField,
rst.Bookmark = bk ' Return to last place and continue search.
rst.FindNext strCriteria ' Find next employee.

Exit Sub
MsgBox "Error: " & Err.Number & " " & Err.Description
End Sub

Many thanks

Nov 13 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.