dbTalk Databases Forums  

Update a treeview node?

comp.databases.ms-access comp.databases.ms-access


Discuss Update a treeview node? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Steve P.
 
Posts: n/a

Default Update a treeview node? - 07-29-2010 , 10:28 AM






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?

Reply With Quote
  #2  
Old   
Steve P.
 
Posts: n/a

Default Re: Update a treeview node? - 07-29-2010 , 02:46 PM






On Jul 29, 11:28*am, "Steve P." <x... (AT) monkeybutler (DOT) com> wrote:
Quote:
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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.