Treeview Nodes and calling functions

R

Ryan

Hello,
I have created a treeview in a main form that calls its nodes from 2 tables.
a cat. table and a subcat table. this took some time as I am not very
familiar with treeview. This is all working fine now. What I would like to
be able to do is call a function in a module when the subcat node is clicked
based on what text is used in the sub node:

example:

If subnode is "Create CPAR", when this is clicked I would liketo call a
function in a module called Create CPAR().

Not sure how to go about this??

I am using Access2007.

Any help would be appreciated.

thanks
Ryan
 
C

ChrisO

' This is hardly likely to work first time.
' It also means each node would need to be unique.
' That also means if you have 500 nodes you will need 500 Functions.
' That's probably not a good idea.
' PreProjects is the name of my TreeView Control and will need to be changed.
' Only tested in A2K3 and if it doesn't work in A2K7 I can't help further.
Private Sub PreProjects_NodeClick(ByVal objNode As Object)
Dim lngPosition As Long

Const conTreeViewPathSeparator As String = "\"

With objNode
' If node is a child then it should
' have a Path Separator in its FullPath
lngPosition = InStrRev(.FullPath, conTreeViewPathSeparator)

' If it has then replace all spaces with underscores and call it.
If (lngPosition) Then
Application.Run Replace(Mid$(.FullPath, lngPosition + 1), " ",
"_")
End If
End With

End Sub
 
R

Ryan

Thanks Chris, but I could not get it to work..tried using call Node.fullpath
but the call function doesnot support this...so back to the drawing board.

Thanks for your time
 
C

ChrisO

It works as posted in A2K3.

Can you post the exact code you used in the Private Sub
PreProjects_NodeClick(ByVal objNode As Object) event?

The entire Sub please.

Can you also state exactly why you want to do it because it may be fraught
with danger.
 

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