Advertisement

01.20.2007 at 07:49AM PST, ID: 22130010
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

TreeView - Child of a Child Problem

Asked by dannywareham in Microsoft Access Database

Tags:

Hi Chaps

I'm having a real blonde day.

I have a treeview that is arranged like this:

Parent1
  Child1
  Child2
     ChildChild1
        ChildChildChild1

The contents are populated dynamically (function attached).
I have no problem adding nodes or children. However, I am having a problem selecting the child's child in order to add the new node (pointer in code)

Any Ideas...?


Function CreateTreeView()

'Create treeview stuff
    Dim TVWControl As TreeView
    Dim lngRoot As Node
    Dim lKey As Long
    Dim mySQLFamily As String
    Dim myRSTFamily As ADODB.Recordset
    Dim mySQLSubFamily As String
    Dim myRSTSubFamily As ADODB.Recordset
    Dim mySQLProject As String
    Dim myRSTProject As ADODB.Recordset
    Dim myFamilyID As Long
    Dim myFamilyName As String
    Dim mySubFamilyID As Long
    Dim mySubFamilyName As String
    Dim myProjectID As Long
    Dim myProjectName As String
   
   
    Set TVWControl = Me.treeNavView.Object

'clear current nodes
    TVWControl.Nodes.Clear

'First, set "fixed" parent

'Home
    Set lngRoot = TVWControl.Nodes.Add(, , "Home", "My Home", 4)

'Projects (with recordset to fill in)
    Set lngRoot = TVWControl.Nodes.Add(, , "Projects", "Projects", 5)

    'Add children
       
    'First Level - Family
        mySQLFamily = "SELECT * FROM tblFamily ORDER BY strFamily_Name"
        Set myRSTFamily = New ADODB.Recordset
        myRSTFamily.Open mySQLFamily, CurrentProject.Connection
            Do While Not myRSTFamily.EOF
                myFamilyID = myRSTFamily.Fields("lngFamily_ID")
                myFamilyName = myRSTFamily.Fields("strFamily_Name")

                'Add Node (FamilyID has to be string now)
                lKey = TVWControl.Nodes.Item("Projects").index
                TVWControl.Nodes.Add lngRoot.index, tvwChild, Chr(34) & "F" & myFamilyID & Chr(34), myFamilyName, 2
               
                'Now we add this node's children
                    mySQLSubFamily = "SELECT * FROM tblSubFamily WHERE lngFamily_ID=" & myFamilyID & " ORDER BY strSubFamily_Name"

                    Set myRSTSubFamily = New ADODB.Recordset
                    myRSTSubFamily.Open mySQLSubFamily, CurrentProject.Connection
                        Do While Not myRSTSubFamily.EOF
                            mySubFamilyID = myRSTSubFamily.Fields("lngSubFamily_ID")
                            mySubFamilyName = myRSTSubFamily.Fields("strSubFamily_Name")
                           
                            'Add node (child of child)
                            lKey = TVWControl.Nodes.Item(myFamilyName).index '<---------------------------------------------- This line to select child not working
                            TVWControl.Nodes.Add lngRoot.index, tvwChild, Chr(34) & "S" & mySubFamilyID & Chr(34), mySubFamilyName, 2

                            myRSTSubFamily.MoveNext
                        Loop
                    myRSTSubFamily.Close
                    Set myRSTSubFamily = Nothing

                myRSTFamily.MoveNext
            Loop
            myRSTFamily.Close
            Set myRSTFamily = Nothing
   
'Fixed stuff again
'Reports
    Set lngRoot = TVWControl.Nodes.Add(, , "Reports", "My Reports", 6)
'Admin
    Set lngRoot = TVWControl.Nodes.Add(, , "Admin", "System Admin", 1)
'Help
    Set lngRoot = TVWControl.Nodes.Add(, , "Help", "Help", 9)
'Log Out
    Set lngRoot = TVWControl.Nodes.Add(, , "Exit", "Log Out", 3)

End FunctionStart Free Trial
[+][-]01.20.2007 at 11:58AM PST, ID: 18357495

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Access Database
Tags: child
Sign Up Now!
Solution Provided By: WarpNine
Participating Experts: 1
Solution Grade: B
 
 
[+][-]01.21.2007 at 02:33AM PST, ID: 18359209

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.21.2007 at 10:55AM PST, ID: 18360514

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy