Refer to a Treeview

davidmreid
NewLounger
Posts: 12
Joined: 19 Feb 2014, 01:45

Refer to a Treeview

Post by davidmreid »

Hi Jan, I redesigned my treeview from my original posting as listed below. Now I don't have to do any extra coding as the logic (mostly) flows down the tree.

-Client Name (root)
--Choose Option
----View Data
----Import Data
----Export Data
--Set Month
--Add Report

I also use an import procedure that resides in a standard module--which leads me to my next question. Could you please let me know how to reference the treeview from a module? I am reading data from 15 queries into a table. As each query is read, I want to highlight the node associated with that query. I put the import in a standard module as the code in the form module is getting quite lengthy. Thank you for your help. -David

davidmreid
NewLounger
Posts: 12
Joined: 19 Feb 2014, 01:45

Re: Refer to a Treeview

Post by davidmreid »

I tried the following reference and several similar attempts:

Private Sub HighlightMyNode(sKey as string)
Dim myView As clsTreeview
Dim myNode As clsNode
Set myView = Forms!frmMain!sbfMain.Form.Controls("MyTree")
With myView
Set myNode = .Nodes(sKey)
Set .ActiveNode = myNode
myView.ScrollToView myNode
.Refresh
Call WaitForMe(5)
End With

My test code works fine in the form module (without the treeview reference and the import procedure) as I just loop through the nodes (pausing for two seconds at each node or the code slams through too fast).

User avatar
Jan Karel Pieterse
Microsoft MVP
Posts: 656
Joined: 24 Jan 2010, 17:51
Status: Microsoft MVP
Location: Weert, The Netherlands

Re: Refer to a Treeview

Post by Jan Karel Pieterse »

I see little benefit in moving code that belongs to the treeview to a normal module. You are fragmenting the code that way, making it harder to maintain.
How many lines of code does the form module have?
Regards,

Jan Karel Pieterse
Excel MVP jkp-ads.com