From: Steve P. on 29 Jul 2010 11:28 Here is a code snippet that I use to populate a treeview control: Do Until rst.NoMatch ' Extract the category name an count of related products strText = rst![catname] & " - " & DCount("id", "PRODUCTS", "catid = " & rst![id]) ' Add as a child node to the tree. Set nodCurrent = objTree.Nodes.Add(nodParent, tvwChild, "a" & _ rst!id, strText) ' Save your place in the recordset. bk = rst.Bookmark ' Add any subcategories. AddChildren nodCurrent, rst ' Return to your place in the recordset and continue to search. rst.Bookmark = bk ' Find the next subcategory. rst.FindNext "[parentid]=" & Mid(nodParent.Key, 2) Loop You can see I use DCount to find how many products are in the category and then display it next to the category name in the treeview. If I change the [catid] of a product I would like to use the AfterUpdate event to update the counts on my treeview. Any ideas on how to do this?
From: Steve P. on 29 Jul 2010 15:46 On Jul 29, 11:28 am, "Steve P." <x...(a)monkeybutler.com> wrote: > Here is a code snippet that I use to populate a treeview control: > > Do Until rst.NoMatch > ' Extract the category name an count of related products > strText = rst![catname] & " - " & DCount("id", "PRODUCTS", > "catid = " & rst![id]) > ' Add as a child node to the tree. > Set nodCurrent = objTree.Nodes.Add(nodParent, tvwChild, "a" & > _ > rst!id, strText) > ' Save your place in the recordset. > bk = rst.Bookmark > ' Add any subcategories. > AddChildren nodCurrent, rst > ' Return to your place in the recordset and continue to > search. > rst.Bookmark = bk > ' Find the next subcategory. > rst.FindNext "[parentid]=" & Mid(nodParent.Key, 2) > Loop > > You can see I use DCount to find how many products are in the category > and then display it next to the category name in the treeview. If I > change the [catid] of a product I would like to use the AfterUpdate > event to update the counts on my treeview. Any ideas on how to do > this? Solved. The treeview and txtCatId are on different subforms located on the same frmMain. Private Sub txtCatId_AfterUpdate() Me.Requery Me.Parent.frmTreeview.Form.xTree.Nodes.Clear Me.Parent.frmTreeview.Form.Form_Load
|
Pages: 1 Prev: Strange List Box Problem Next: Will Access 2010 run a 2003 program? |