X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> TreeView question    
post Jun 12 2007, 10:18 AM

Posts: 626
Joined: 26-December 02
From: Raleigh, North Carolina

Is there any way to type a value in a textbox and then select that value in the tree view? Kind of like a search to find a record in the tree and have it expand and stuff. I don't know anything about Tree Views, so the simpler, the better.
Thanks a bunch
Go to the top of the page
post Jun 12 2007, 10:50 AM

UtterAccess Editor
Posts: 17,956
Joined: 4-December 03
From: Northern Virginia, USA

Word of warning ... TreeViews can be a daunting task to conquer!! ... Everything needs to be handled in code. The code can get big ... with that in mind, I have attached a sample as opposed to pasting the code in the post.

I hope you find the sample helpful!

PS> This is an "update" to the LAST one I posted in this thread ...
Attached File(s)
Attached File  TreeViewSample.zip ( 90.14K )Number of downloads: 2412
Go to the top of the page
Dom DXecutioner
post Jun 12 2007, 10:57 AM

Posts: 1,155
Joined: 18-November 03
From: California


The short-n-short answer, yes, it's doable; however, you must take into cosideration the fact that you may have a value more than once loaded onto the treeview. You must come up with a method to handle this situation.

Furthermore, you must also think of the way on how you wish to do the search, full text or partial. The code below will demostrate how to accomplish the basics, I use late binding for compatibility purposes...

Private Sub SearchTreeview(strSearchString As String)
#91;color="green"]'// object variables[/color]
Dim tv As Object
Dim nod As Object
    [color="green"]'// load object pointers[/color]
    Set tv = Me.xTree.Object

    For Each nod In tv.Nodes
        If nod.Text = strSearchString Then
            [color="green"]'// string found, selected and change the color to red[/color]
            With nod
                  .Selected = True
                  .ForeColor = vbRed
            Exit Sub
            [color="green"]'// string not found, notify user[/color]
            MsgBox "Your text was not found!"
        End If
    Next nod
    [color="green"]'// free resources[/color]
    Set tv = Nothing
    Set nod = Nothing
End Sub

I was beaten to the answer, but thought i'd share my 2 cents; besides, it was already typed... good luck.

Edited by: Xyon-X on Tue Jun 12 12:00:52 EDT 2007.
Go to the top of the page
post Jun 12 2007, 11:22 AM

Posts: 626
Joined: 26-December 02
From: Raleigh, North Carolina

Thanks for both of the responses.
rent - I know that trees are huge, there is one that already exists in the database that is being rebuilt and everyone likes it.
X Actually, this is already taken care of. The data that is shown in the tree is unique.
I will try it out and let you know how it goes. Keep your fingers crossed.
Go to the top of the page
post Mar 3 2009, 10:59 AM

Posts: 1
Joined: 3-March 09

I am very grateful for this example. At this very moment I am trying to get my brain around the complexities of the TreeView control. The concepts are just starting to make sense.
You state in your mod_TreeViewCommon module that the Recordset can be passed as DAO, ADO, or SQL string. Do you favor one over the others? If so, why?
Go to the top of the page
post Mar 6 2009, 06:54 AM

UtterAccess VIP
Posts: 3,646
Joined: 3-November 03
From: Near Toronto, ON, CA

Hey Tina- welcome to UA! Your post probably got lost down here as a response to an old thread. You might want to start a new thread and Brent will probably see it and can comment specifically on his solution- he's pretty active here.
On the meantime if you're starting at the beginning with treeviews you might want to look here.
Go to the top of the page
post Apr 17 2009, 01:43 AM

UtterAccess Editor
Posts: 17,956
Joined: 4-December 03
From: Northern Virginia, USA

Wow ... It was by happenstance that I found your question to me ...
I am glad you liked the TreeView sample. With respect to DAO, ADO, or a SQL Statement preference .... well I do not really have a preference as I use what I need, thus the development of the code to accept all three. If all three are valid options ... well why don't I just say this: If I have a DAO recordset that can populate the treeview, then I use it. The same goes for an ADO recordset. But I often will use an SQL Statement too just because it offers a lot of flexibility.
Go to the top of the page
post Nov 7 2011, 09:57 PM

Posts: 1
Joined: 7-November 11

I'm new at VBA development and I was getting mad at my embedded TreeView control because of drag and drop functions declaration. Now I solved this issue <
Just wanna say thanks for your help datAdrenaline! Your example has been quite useful!
Go to the top of the page
post Dec 20 2011, 05:36 AM

Posts: 117
Joined: 22-July 02
From: Texas,U.S.A.

Hey Guys, been years since I been on the forum. I, like others had a hard time grasping the TreeView Control in access but always wanted to use it. I wanted to say thanks to Clippit for the link to 'My MS Access Blog'. The link goes to 'My TreeView Project' Posted by Stephen who I would also like to thankn. This tutorial is absolutely one of the best! I breezed through it, and I am now able to take what I learned to a new level. Thanks for taking the time and really explaining it!
Go to the top of the page
post Nov 18 2012, 12:46 AM

Posts: 1
Joined: 25-September 12

need to have search for list view & to generate the report based on check box I selected in Treeview & List box, kindly help me.
Go to the top of the page

Custom Search
RSSSearch   Top   Lo-Fi    22nd May 2018 - 05:06 AM