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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Navigation tree 1

Status
Not open for further replies.

oraclejunior

Technical User
Jul 8, 2003
111
0
0
GB
Hi I am currently creating a system that requires a navigation tree/bar on the LHS of the form. I want it to take the form of a tree that can be expanded and minimised by clicking on (+) and (-) signs.

The hierachical structure will be:

A project has a number of registers, each register has a number of issues.

Click on the project and it expands out all the registers
Click on the register and it expands out all the issue ID's.

The user then clicks on the Issue ID to view/edit and delete details within the main form.

How can the navigation tree be created?

Thanks
 
Have you considered the Treeview Control?
 
can you please explain the treeview control and how it can be implemented. i.e is it hardcoded in oir can a wizard be used to create it.

Thanks
 
I have the following tables, IssueRegister and Issues

IssueRegister has following fields (IRID (PK), Name....)
Issue has following fields (IssueID (PK), IRID (FK)....)

How do I code a tree to show IssueRegister Name and then the issues when the tree is expanded when clicking on the register.

e.g.

(+) HR Register
(+) Payroll Register
(+) Marketing Register

then when I click on HR Register
(-) HR Register
ISSUE1
ISSUE2
.....etc

Help would be greatly appreciated as I have hit new territoty.

Thanks





 
This is adapted from thread702-879892 and tested on Microsoft Treeview Control v.6

Code:
Function BuildTreeSimple()
    Dim rsRegister As DAO.Recordset
    Dim rsIssue As DAO.Recordset

    Dim nodTable As Node
    Dim nodField As Node
    
    Set rsRegister = CurrentDb.OpenRecordset("IssueRegister")
    
    Do While Not rsRegister.EOF()
        Set nodTable = tvwTreeView.Nodes.Add(, , "a" & rsRegister!IRID, rsRegister![RegisterName])
        
        Set rsIssue = CurrentDb.OpenRecordset("Select * From Issue Where IRID=" & rsRegister!IRID)
        Do While Not rsIssue.EOF()
     
            Set nodField = tvwTreeView.Nodes.Add(nodTable, tvwChild, "b" & rsIssue!IssueID, rsIssue!Issue)
            rsIssue.MoveNext
        Loop
        rsRegister.MoveNext
    Loop
End Function

Private Sub Form_Open(Cancel As Integer)
    BuildTreeSimple
End Sub

You will need to set some properties of the control.
Style : 6 tvwTreelinesPlusMinusText
LineStyle : 1 tvwRootlines
 
I have set the above code for a risk register but i get a runtime error 424 Object Required Error: on the line nodtable =....

Function BuildTreeSimple()
Dim rsRegister As DAO.Recordset
Dim rsRisk As DAO.Recordset

Dim nodTable As Node
Dim nodField As Node

Set rsRegister = CurrentDb.OpenRecordset("Register")

Do While Not rsRegister.EOF()
Set nodTable = tvwTreeView.Nodes.Add(, , "a" & rsRegister!RegisterID, rsRegister![RegName])
Set rsRisk = CurrentDb.OpenRecordset("Select * From Risk Where RegisterID=" & rsRegister!RegisterID)
Do While Not rsRisk.EOF()

Set nodField = tvwTreeView.Nodes.Add(nodTable, tvwChild, "b" & rsRisk!RiskID, rsRisk!RiskTitle)
rsRisk.MoveNext
Loop
rsRegister.MoveNext
Loop
End Function
 
Did you create a treeview control named tvwTreeView ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
What is the name of your treeview control? In my test, the control was called tvwTreeView.
 
Dough, Just renamed the control...I am jumping with joy.

Does this mean that if I click on the risk I can have a form refresh using the risk ID to pull up the details.

Thanks
 
The ID has an 'a' attached, treeview seems to insist on an alpha, so you will need to do a little coding to get this to work or, perhaps, change the control a bit.
 
There are 3 levels that the register can sit in:

Level 1 - Strategic, Level 2 - Business, Level 3 - Project.

The level table has PK LevelID and each register has a fk Level ID. How can this be encorporated to the above code so the tree shows:

Level
Register
Risks

Thank you.
 
The second link in my original post shows three levels.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top