M
Matt
Hello NG
I populating a treeview control with the employee data from the tblemployee
table (fields: PersonalID (Replication ID); First (Text); Last (Text);
ReportsToID(Replication ID)) with the code below.
For the supervisors the replication ID in the [ReportsToID] field is empty.
How do I have to formulate the Find.First for the supervisors?
rst.FindFirst StringFromGuid(ReportsToID) = " & "" 'didn't work :-(
Pls. help
Thank you very much
Matt
Private Sub Form_Load()
Dim nodCurrent As node
Dim strText As String, nodRoot As node
Dim bk As String, node As node
Dim objTree As TreeView
Set db = CurrentDb
Set rst = db.OpenRecordset("tblEmployees", dbOpenDynaset)
If rst.EOF Then
Exit Sub
Else
' Create a reference to the TreeView Control.
Set objTree = Form_Employee!xTree.Object
' Find first Employee without supervisor
rst.FindFirst StringFromGuid(ReportsToID) = " 'what should I put here?
"" didn't work
' Build the TreeView list with supervisor and employees
Do Until rst.NoMatch
' Extract employee_name.
strText = rst![First] & " " & rst![Last]
' Add a root level node to the tree for the parent process
Set nodCurrent = objTree.Nodes.Add(, , "a" & rst!PersonalID, strText,
Int(rst!Image))
' Use a placeholder to save this place in the recordset.
bk = rst.Bookmark
' Run a recursive procedure to add all the child nodes für
AddChildren nodCurrent, rst
' Return to your placeholder.
rst.Bookmark = bk
' Find the next supervisor.
rst.FindNext StringFromGuid(ReportsToID) = " 'what should I put here?
Loop
End Sub
Sub AddChildrenA(nodboss As node, rst As DAO.Recordset)
Dim nodCurrent As node
Dim objTree As TreeView, strText As String, bk As String
Dim db As DAO.Database
Dim strGuid as String
' Create a reference to the TreeView control.
Set objTree = Form_Employee!xTree.Object
strGuid = StringFromGuid("[ReportsToID])
' Find the first employee who reports to the supervisor for this
' node.
rst.FindFirst "[ReportsToID] =" & strGuid
' Build the list of employees who report to this supervisor.
Do Until rst.NoMatch
' Extract the employee's name.
strText = rst![First] & " " & rst![Last]
' Add as a child node to the tree.
Set nodCurrent = objTree.Nodes.Add(nodboss, tvwChild, "a" &
rst!PersonalID, strText, Int(rst!Image))
' Save your place in the recordset.
bk = rst.Bookmark
' Add any employees for whom the current node is a supervisor.
AddChildren nodCurrent, rst
' Return to your place in the recordset and continue to search.
rst.Bookmark = bk
' Find the next employee who reports to this supervisor.
rst.FindNext "[ReportsToID]=" & strGuid
Loop
End Sub
I populating a treeview control with the employee data from the tblemployee
table (fields: PersonalID (Replication ID); First (Text); Last (Text);
ReportsToID(Replication ID)) with the code below.
For the supervisors the replication ID in the [ReportsToID] field is empty.
How do I have to formulate the Find.First for the supervisors?
rst.FindFirst StringFromGuid(ReportsToID) = " & "" 'didn't work :-(
Pls. help
Thank you very much
Matt
Private Sub Form_Load()
Dim nodCurrent As node
Dim strText As String, nodRoot As node
Dim bk As String, node As node
Dim objTree As TreeView
Set db = CurrentDb
Set rst = db.OpenRecordset("tblEmployees", dbOpenDynaset)
If rst.EOF Then
Exit Sub
Else
' Create a reference to the TreeView Control.
Set objTree = Form_Employee!xTree.Object
' Find first Employee without supervisor
rst.FindFirst StringFromGuid(ReportsToID) = " 'what should I put here?
"" didn't work
' Build the TreeView list with supervisor and employees
Do Until rst.NoMatch
' Extract employee_name.
strText = rst![First] & " " & rst![Last]
' Add a root level node to the tree for the parent process
Set nodCurrent = objTree.Nodes.Add(, , "a" & rst!PersonalID, strText,
Int(rst!Image))
' Use a placeholder to save this place in the recordset.
bk = rst.Bookmark
' Run a recursive procedure to add all the child nodes für
AddChildren nodCurrent, rst
' Return to your placeholder.
rst.Bookmark = bk
' Find the next supervisor.
rst.FindNext StringFromGuid(ReportsToID) = " 'what should I put here?
Loop
End Sub
Sub AddChildrenA(nodboss As node, rst As DAO.Recordset)
Dim nodCurrent As node
Dim objTree As TreeView, strText As String, bk As String
Dim db As DAO.Database
Dim strGuid as String
' Create a reference to the TreeView control.
Set objTree = Form_Employee!xTree.Object
strGuid = StringFromGuid("[ReportsToID])
' Find the first employee who reports to the supervisor for this
' node.
rst.FindFirst "[ReportsToID] =" & strGuid
' Build the list of employees who report to this supervisor.
Do Until rst.NoMatch
' Extract the employee's name.
strText = rst![First] & " " & rst![Last]
' Add as a child node to the tree.
Set nodCurrent = objTree.Nodes.Add(nodboss, tvwChild, "a" &
rst!PersonalID, strText, Int(rst!Image))
' Save your place in the recordset.
bk = rst.Bookmark
' Add any employees for whom the current node is a supervisor.
AddChildren nodCurrent, rst
' Return to your place in the recordset and continue to search.
rst.Bookmark = bk
' Find the next employee who reports to this supervisor.
rst.FindNext "[ReportsToID]=" & strGuid
Loop
End Sub