Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Nov 2002
    Location
    San Francisco, California
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    treeview control--subnode click event poss? (Access 2000 SR 1)

    I built a treview control that collapses/expands fine. I wanted to add event procedures for each sub-node (or Child) node ie, open a query or table for each Child node. I added code to the NodeClick event, but it performs the same event for All child nodes. What am I missing?

    Current Process:

    Parent 1
    Child 1 opens query 1
    Child 2 opens query 1
    Parent 2
    Child 1 opens query 1
    Child 2 opens query 1

    Ideal Process:

    Parent 1
    Child 1 opens query 1
    Child 2 opens query 2
    Parent 2
    Child 1 opens query 3
    Child 2 opens query 4

    Any ideas would be appreciated.

    Thanks!

  2. #2
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: treeview control--subnode click event poss? (Access 2000 SR 1)

    All nodes share the save event....they do not have a click event each. To determine which node was clicked, as part of the event, a node object is returned, you can use this to determine which node was clicked.

    TreeView.NodeClick = Event NodeClick(Node as Object)

    Important to note, that this event is actually an event of the TreeView control and not the Nodes themselves!

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: treeview control--subnode click event poss? (Access 2000 SR 1)

    Another way to do it, that I have used in the past in Access is to use the Click event of the TreeView control, then use the property .SelectedItem, to return the node that is selected: ie.

    Private Sub tvw_Click()
    Dim ndeSel as Object

    set ndeSel = tvw.SelectedItem
    msgbox ndeSel.Key

    set ndeSel = nothing
    End Sub

  4. #4
    New Lounger
    Join Date
    Nov 2002
    Location
    San Francisco, California
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: treeview control--subnode click event poss? (Access 2000 SR 1)

    Thanks!

    I figured it out thanks to a variation of your reply.

    Private Sub trvwTest_NodeClick(ByVal Node As Object)

    Set trvw = trvwTest.Object
    Set NodeSel = trvw.SelectedItem

    If NodeSel.Key = "013L3" Then
    DoCmd.OpenTable "tblName"
    End If

    Set NodeSel = Nothing
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •