TreeView

tamer137

New member
Local time
Today, 13:28
Joined
Dec 4, 2014
Messages
2
Hi, how are you
I design the attached program
And I wanted code to link TreeView to reports
I have linked TreeView to Format
But I don't know how to link TreeView reports

Code:
Private Sub Form_Load()
    Dim OldLong As Long
    Dim nodX As Node
    Set nodX = TreeView1.Nodes.ADD(, , "A", "System", 4)
    Set nodX = TreeView1.Nodes.ADD(, , "B", "Report", 3)
    Set nodX = TreeView1.Nodes.ADD("A", tvwChild, "C1", "Company Info", 1)
    Set nodX = TreeView1.Nodes.ADD("A", tvwChild, "C2", "Users", 5)
    Set nodX = TreeView1.Nodes.ADD("A", tvwChild, "C3", "Passwords", 6)
    Set nodX = TreeView1.Nodes.ADD("A", tvwChild, "C4", "VIP", 2)
    Set nodX = TreeView1.Nodes.ADD("B", tvwChild, "C5", "Report 1", 3)
    Set nodX = TreeView1.Nodes.ADD("B", tvwChild, "C6", "Report 2", 3)
    nodX.EnsureVisible
    OldLong = GetWindowLong(TreeView1.hwnd, GWL_EXSTYLE)
    SetWindowLong TreeView1.hwnd, GWL_EXSTYLE, OldLong Or WS_EX_LAYOUTRTL
    InvalidateRect hwnd, 0, False
    
End Sub
Private Sub TreeView1_Click()
    
    Dim strFormName As String
    Dim formsDictionary As New Scripting.Dictionary
    formsDictionary.ADD "Company Info", "frmCompany"
    formsDictionary.ADD "Users", "frmSystemUserData"
    formsDictionary.ADD "Passwords", "frmPassword"
    formsDictionary.ADD "VIP", "frmDeveloper"
    strFormName = TreeView1.SelectedItem.Text
    If formsDictionary.Exists(strFormName) Then
        DoCmd.OpenForm formsDictionary(strFormName)
    End If
End Sub
 

Attachments

Use the nodes tag property to store the name but prefix the object name.
Rep reportname1
Rep reportname2
Frm formname1

Read the tag
Read left 3 to determine what type of object
Open mid(node.tag,5)
 
pls give up treeview. it takes a lot of programming.
instead use either :
the switchboard (just enter values)
or
a listbox with a combo box in the header to filter records. (add query values to a table)
 
i can't modify your original form (maybe it's because of Arabic language) so i made Form1.
see the Code of the Load event of this form.
 

Attachments

Users who are viewing this thread

Back
Top Bottom