Direct access to Treeview Item

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?


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.