Direct access to Treeview Item

Posted on 2006-03-28
Last Modified: 2009-05-25
I am using Treeview Control 6.0 with Access 2002.

My "main form" has the Treeview control on it.  Clcik the add button and I open another form to add a record.  The table I added the record to is the same table that is the datasource for my treeview.

I have figured out how to refresh (read as repopulate the entire control) the treeview control so the new item appears where it should within the tree.  

But now I want to have the treeview sit on the new record I just added.

Does anyone have an idea of how to do this?


Question by:gandrews081397
    LVL 84

    Accepted Solution

    Something like this will work:

      Dim tvw  As TreeView
      Dim nod  As Node
      On Error GoTo Err_Command1_Click
      '/set our code object to the form's control
      Set tvw = Me.treex.Object
      '/now run through the nodes
      '/note we could also use the nod.Key value, if you want to search by the key
        For Each nod In tvw.Nodes
            If nod.Text = Me.Text2 Then
              '/found the node; select it
              tvw.SelectedItem = tvw.Nodes(nod.Index)
              nod.Selected = False
            End If
        Next nod

    Note that how you actually search for the node (i.e. nod.Text or nod.Key) would be dicatated by how you are filling the nodes.
    LVL 27

    Expert Comment

    No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

    I will leave the following recommendation for this question in the Cleanup topic area:
        Accept: LSMConsulting {http:#16316121}

    Any objections should be posted here in the next 4 days. After that time, the question will be closed.

    EE Cleanup Volunteer

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now