Direct access to Treeview Item

Posted on 2006-03-28
Medium Priority
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 85

Accepted Solution

Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 16316121
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

ID: 16855647
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Beware when using the ListIndex and the Column() properties of a listbox in Access 2007.  A bug has been identified in the Access 2007 listbox code which can cause the .ListIndex property to return a -1, and the .Columns(#) property to return a NULL…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

578 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