I follow this lesson "mymsaccessblog.blogspot.ca/2008/02/my-treeview-project-episode-two.html"
to learn about the TreeView Control and when I open the form in FormView I get the Debug error message "Item not found in this collection" and the line in red is highlighted on the code below.
Option Compare Database
Private Sub CreateCategoryNodes()
Dim rst As DAO.Recordset ' recordset for category data
' open the recordset for categories
Set rst = CurrentDb.TableDefs!Categories.OpenRecordset
' loop through the rows in the recordset
rst.MoveFirst
Do Until rst.EOF
Me.xProductTreeView.Nodes.Add Text:=rst!CategoryName, _
Key:="Cat=" & CStr(rst!CategoryID)
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
End Sub
Am I correct to say that the error occurs because the Product table (where the rst should come from) is not set properly? Like it should be:
Set rst=db.OpenRecordset("Products", dbOpenDynaset, dbReadOnly)
to learn about the TreeView Control and when I open the form in FormView I get the Debug error message "Item not found in this collection" and the line in red is highlighted on the code below.
Option Compare Database
Private Sub CreateCategoryNodes()
Dim rst As DAO.Recordset ' recordset for category data
' open the recordset for categories
Set rst = CurrentDb.TableDefs!Categories.OpenRecordset
' loop through the rows in the recordset
rst.MoveFirst
Do Until rst.EOF
Me.xProductTreeView.Nodes.Add Text:=rst!CategoryName, _
Key:="Cat=" & CStr(rst!CategoryID)
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
End Sub
Am I correct to say that the error occurs because the Product table (where the rst should come from) is not set properly? Like it should be:
Set rst=db.OpenRecordset("Products", dbOpenDynaset, dbReadOnly)