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

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » treeview control–subnode click event poss? (Access 2000 SR 1)

    Author
    Topic
    #378835

    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!

    Viewing 1 reply thread
    Author
    Replies
    • #628474

      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!

    • #628477

      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

      • #628504

        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

    Viewing 1 reply thread
    Reply To: treeview control–subnode click event poss? (Access 2000 SR 1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: