G
Guest
Folks, I copied, word for word, code I found from Microsoft's KB article
209898. I'm using Access 2003, not 2000, but that shouldn't matter here.
Here's the code:
Private Sub Form_Load()
On Error GoTo ErrForm_Load
Dim db As Database
Dim rst As Recordset
Dim nodCurrent As Node, nodRoot As Node
Dim objTree As TreeView
Dim strText As String, bk As String
Set db = CurrentDb
Set rst = db.OpenRecordset("Employees", dbOpenDynaset, dbReadOnly)
Set objTree = Me!xTree.Object
rst.FindFirst "[ReportsTo] Is Null"
Do Until rst.NoMatch
strText = rst![LastName] & (", " + rst![FirstName])
Set nodCurrent = objTree.Nodes.Add(, , "a" & rst!EmployeeID, _
strText)
bk = rst.Bookmark
AddChildren nodCurrent, rst
rst.Bookmark = bk
rst.FindNext "[ReportsTo] Is Null"
Loop
ExitForm_Load:
Exit Sub
ErrForm_Load:
MsgBox Err.Description, vbCritical, "Form_Load"
Resume ExitForm_Load
End Sub
Here's my problem; as soon as the program gets to line: Set nodCurrent =
objTree.Nodes.Add(, , "a" & rst!EmployeeID, strText), I get an error 13: Type
Mismatch. Can anyone offer any assistance as to why this isn't working?
Thanks!
209898. I'm using Access 2003, not 2000, but that shouldn't matter here.
Here's the code:
Private Sub Form_Load()
On Error GoTo ErrForm_Load
Dim db As Database
Dim rst As Recordset
Dim nodCurrent As Node, nodRoot As Node
Dim objTree As TreeView
Dim strText As String, bk As String
Set db = CurrentDb
Set rst = db.OpenRecordset("Employees", dbOpenDynaset, dbReadOnly)
Set objTree = Me!xTree.Object
rst.FindFirst "[ReportsTo] Is Null"
Do Until rst.NoMatch
strText = rst![LastName] & (", " + rst![FirstName])
Set nodCurrent = objTree.Nodes.Add(, , "a" & rst!EmployeeID, _
strText)
bk = rst.Bookmark
AddChildren nodCurrent, rst
rst.Bookmark = bk
rst.FindNext "[ReportsTo] Is Null"
Loop
ExitForm_Load:
Exit Sub
ErrForm_Load:
MsgBox Err.Description, vbCritical, "Form_Load"
Resume ExitForm_Load
End Sub
Here's my problem; as soon as the program gets to line: Set nodCurrent =
objTree.Nodes.Add(, , "a" & rst!EmployeeID, strText), I get an error 13: Type
Mismatch. Can anyone offer any assistance as to why this isn't working?
Thanks!