Ron,
Your initial assumption is correct. I want to output the data not the
graphical representation. I've been exploring various articles on the
subject but it is the unknown levels that I keep getting hung up on.
Two more question about treeview.
1. After my treeview is created, only the highest value is visible and you
have to drill down to see the lower levels. Is there a way to expand or
explode all levels once the tree build is complete?
2.
3. After I implemented your original code suggestion I went back and changed
some things that I though would not make a difference. Note that
strTableQueryName is qry_BOM_Tree (the file my treeview is constructed from.)
What I did was placed a parameter in that query to select records matching
BOM_ID on frm_BOM_inq. Meaning in the criteria fields I added
[forms].[frm_BOM_inq].[BOM_ID]. If I run the query is works fine. But when
I click on my Tree Refresh botton it errors at line 6 stating Too Few
Parameters. Expected 1.
If I open the query and set the criteria manually and save it an press the
Refresh Button, that works.
How can I get the Forms BOM_ID to feed the qry_BOM_Tree so that When I build
the tree it is for the selected Product
CODE:
1 Private Sub btnRefreshTree_Click()
2 Const strTableQueryName = "qry_BOM_Tree"
3 Dim db As DAO.Database, rs As DAO.Recordset
4 Dim objTree As TreeView
5 Set db = CurrentDb
6 Set rs = db.OpenRecordset(strTableQueryName, dbOpenDynaset, dbReadOnly)
7 Set objTree = Me!xTree.Object
8 objTree.Nodes.Clear
9 AddBranch rs:=rs, strPointerField:="Parent_ID", strIDField:="Child_ID",
strTextField:="PartNumber", strDescField:="PartDesc", strQty:="Child_Qty"
End Sub
Ron Weiner said:
There are a number of methods that can be used to Populate a tree. Many
people will use a recursive algorithm and that is gonna be tougher to
organize into the desired out put. In most cases this is that easiest way
to write the code, but for large trees can be painfully slow to populate.
In this case you will likely have to write code that steps through each node
of the tree and either automate excel putting individual values into cells,
or write each node to a file that you could later import into excel.
When you know in advance how many levels deep the tree can ever be, you can
attempt to flatten out (relationally speaking) the trees data into one
(generally very nasty) query that could easily be exported to excel.
Typically this method of populating the tree is VERY fast as there is one
row in the query for each node and there is no recursing, but is a little
more complex to code.
Wow it just occurred to me that you might want the Graphic representation of
the tree, and no the data that the tree was based on. Frankly I have no
idea how you might accomplish that.
Ron W
www.WorksRite.com
file
or sample
in (How
to can
add