TreeView (1 Viewer)

tamer137

New member
Local time
Yesterday, 20:42
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

  • MediaSoft.accdb
    5.8 MB · Views: 97

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 23:42
Joined
May 21, 2018
Messages
8,555
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)
 

Ranman256

Well-known member
Local time
Yesterday, 23:42
Joined
Apr 9, 2015
Messages
4,337
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)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:42
Joined
May 7, 2009
Messages
19,247
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

  • MediaSoft.accdb
    5.8 MB · Views: 120

Users who are viewing this thread

Top Bottom