Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expandable Tree Style Navigation on a Form

Status
Not open for further replies.

trevorwilliams2

Programmer
Mar 3, 2003
107
US
I have a Project that I am working on that would really benefit from a tree style form of navigation. (Expandable / Collapsible on a single form)

For instance:
+Project(s)
+NameOfProject
+Goal/Milestones
+Tasks
+Task Details

Has anybody ever tried this or have any suggestions.



 
There is a TreeView control in Access since 2000.

You might have to hit the bottom button on the toolbar (the hammer & wrench) and scroll to Microsoft TreeView.
--Jim
 
I have fully encapsulate the code for this in a class module. When I get home I will send it. It provides a tremendous amount of functionality.
 
I am playing around with some dowloaded examples using the Microsoft Treeview control. I've touched on this in the past but never gave it a real look over. Pretty cool stuff.

MajP, would love to see your example!
 
I use an explorer style view for all of my apps using the treeview for navigation displaying the selected form in the main window. It has the ability to add icons and the menu itself is maintained from a table. The same code has been adapted for treeview navigation of records :) check out MajP's and if your still interested Ill post it

HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work
 
Here is a demo

The bottom line, I have written the code to load any treeview with just this much code. To include self referencing tables.

public tvw as Treeviewform

Private Sub Form_Load()
Set tvw = New TreeviewForm
tvw.Init Me.xTree.Object, "qryCustomers_Orders_OrderDetails", "None"
End Sub

Now the only trick is you have to build a query from you data.
1) For each table the query looks EXACTLY like this for the fields ID, parentID, and nodeText:

SELECT
[Identifier] & [CustomerID] AS ID,
"None" AS parentID,
[CustomerID] & " " & [CompanyName] AS nodeText,
"Cust" AS identifier
FROM Customers;

ID: is a combination of a unique IDentifier and a primary key

parentID: For the highest level table it is "None" unless self referencing. For any other table it is the parent table identifier and the foriegn key (see the demo)

Node Text: Whatever you want in the display
identifier: a unique identifier for the table

Here is the second table.

SELECT
[identifier] & [orders.OrderID] AS ID,
"Cust" & orders.customerID AS parentID,
"Order: " & [OrderID] & " Date: " & [OrderDate] AS nodeText, "Ord" AS identifier
FROM Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID
ORDER BY "Cust" & orders.customerID;

Once you have wrote your queries do a union query on all of the other queries.
To initialize the treeview

tvw.Init Me.xTree.Object, "qryCustomers_Orders_OrderDetails", "None"

where the first parameter is the treeview object
the second is the name of your union query
and the third is the name of the parent ID of your first table


The code has numerous other properties and methods. I think it is better crafted then any MS examples I have seen.

When I use a tree view I want to be able to click on a node and return the primary key to that record so I can then do something with the record. So my treeviews are very particular about unique keys. The biggest difficulty with treeview is ensuring that every single node has a unique key.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top