Hierarchycal TreeView DB

V

vmcduarte

Hello!

I have created a very simple hierarchycal list based on the Adjacency-List
model (see DB attached).

I have also created a form with TreeView to browse the hierarchy.

In the form frmProjectos, from the DB attached, I would like that, when the
user clicks on any Project, the form right shows this Project record.

How can I do this?

Thank you!

You can download the sample DB file from:
http://www.utteraccess.com/forums/uadl.php?Zn=1916276
 
T

Tom van Stiphout

You need a little bit different approach. First off it is highly
convenient if you use the Primary Key as the Node.Key value. Prefixing
"a" is not really helpful.

Then you can write:
Private Sub xTree_NodeClick(ByVal Node As Object)
Debug.Print "You clicked on node " & Node.Key

Dim lngID As Long
lngID = CLng(Mid(Node.Key, 2)) 'Strip trailing char.

With Me.Parent.RecordsetClone
.FindFirst "IDProjecto=" & lngID
If Not .NoMatch Then
Me.Parent.Bookmark = .Bookmark
End If
End With
End Sub

Btw, your code needs more work. For example you should close all
recordset objects when you are done with them, and set to Nothing.

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top