Link to home
Start Free TrialLog in
Avatar of Jeremy Campbell
Jeremy CampbellFlag for United States of America

asked on

How to select top node of treeview in MS Access using VBA?

How can I select the top node of a treeview on load and after expand all?

Here are the two codes I have where I want this to happen:
Private Sub Form_Load()
    Call LoadTreeView
    
    Dim nodThis As MSComctlLib.Node

    For Each nodThis In Me.treeReqs.Nodes
        nodThis.Expanded = True
    Next nodThis
    nodThis.Selected = True

    
    Me.treeReqs.SetFocus
    Me.JobNum = GBL_JobNum
    Me.txtJobNum = GBL_JobNum
    Me.txtAssemblySeq = 0
End Sub

Open in new window


Private Sub cmdOpStatus_Click()
    Me.Application.Echo False
    If Me.cmdOpStatus.Caption = "Show Complete" Then
        Me.cmdOpStatus.Caption = "Hide Complete"
    Else
        Me.cmdOpStatus.Caption = "Show Complete"
    End If
    
    Call LoadTreeView
    Dim nodThis As MSComctlLib.Node
    
    For Each nodThis In Me.treeReqs.Nodes
        nodThis.Expanded = True
    Next nodThis
    Me.treeReqs.SetFocus
    Me.Application.Echo True
End Sub

Open in new window


Thanks for the help!
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeremy Campbell

ASKER

Perfect! Thanks!