Results 1 to 1 of 1
  1. #1
    Join Date
    Sep 2005
    Posts
    5

    Unhappy Unanswered: Need help with VBA qry and loop statement

    Need help trying to create a third node in treeview referencing queries in access. See commented area below.

    Private Sub ExplorerPane_NodeClick(ByVal Node As Object)
    Dim thePane As Form


    Select Case Node.Tag

    Case "Node1"
    Me.fsubNode2.Visible = False
    Me.fsubNode3.Visible = False

    Set thePane = Me.fsubNode1.Form
    thePane.Filter = "Node1_Title = '" & Node.Text & "'"
    thePane.FilterOn = True

    Me.fsubNode1.Visible = True

    Case "Node2"
    Me.fsubNode1.Visible = False
    Me.fsubNode3.Visible = False

    Set thePane = Me.fsubNode2.Form
    thePane.Filter = "Node2_Title = """ & Node.Text & """"
    thePane.FilterOn = True

    Me.fsubNode2.Visible = True

    Case "Node3"
    Me.fsubNode1.Visible = False
    Me.fsubNode2.Visible = False

    Set thePane = Me.fsubNode3.Form
    thePane.Filter = "Node3_Title = """ & Node.Text & """"
    thePane.FilterOn = True

    Me.fsubNode3.Visible = True

    End Select

    End Sub

    Private Sub Form_Load()

    Dim rsNode1 As DAO.Recordset
    Dim qryNode2 As DAO.QueryDef
    Dim rsNode2 As DAO.Recordset
    Dim qryNode3 As DAO.QueryDef
    Dim rsNode3 As DAO.Recordset

    Set rsNode1 = CurrentDb.OpenRecordset("qryNode1List", dbOpenForwardOnly)
    Set qryNode2 = CurrentDb.QueryDefs("qryNode2List")
    Set qryNode3 = CurrentDb.QueryDefs("qryNode3List")

    Do While Not rsNode1.EOF
    Dim theNode1 As Node
    Dim theNode2 As Node

    Set theNode1 = Me.ExplorerPane.Nodes.Add(, , , rsNode1!Node1_Title)
    theNode1.Tag = "Node1"

    With qryNode2
    qryNode2.Parameters(0) = rsNode1!Node1_ID
    Set rsNode2 = qryNode2.OpenRecordset(dbOpenForwardOnly)
    Do While Not rsNode2.EOF
    Set theNode2 = Me.ExplorerPane.Nodes.Add(theNode1, tvwChild, , rsNode2!Node2_Title)
    theNode2.Tag = "Node2"
    rsNode2.MoveNext

    'Here is where I need help - How do I create a 3rd Node using qryNode3List'
    'How do I replicate node2 and get it to use the tags in my qryNode3List'
    'Which tags would I need in qryNode3List?'


    Loop
    End With
    rsNode1.MoveNext

    Loop
    End Sub
    Attached Files Attached Files

Posting Permissions

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