Yes, I am sorry.
I have a form into which I have inserted a tree control. The tree shows
raw
materials under a Level 1 and level 2 category header. The window control
works fine.
Now, what I want to do is to display detail information on another part of
the form about a material that is clicked on in the tree control. The
form
is based on a query containing information about each material.
So, in short, what I want to happen is when I select an item in the tree,
the value of that item (most likely the item name, which in your generic
example you referred to as "text") is pushed into the forms query, which
then
filters the recordset, and displays detail information about that item on
the
form.
I have attached the code I used to populate the tree control. The forms
query has a field called Suncode which would equal the sparentname.
Private Sub Form_Load()
Dim FormNode As Node
Dim rs As Object
Dim sParentId As String
Dim sProductId As String
Dim sProductName As String
Dim sProductGroupName, sProductGroupKey As String
With TreeView3
.Nodes.Clear
.Indentation = 2
.Style = 7
Set FormNode = .Nodes.Add(, , "Root", "Raw Materials " & "(" &
"Green are Core, Red are Non-Core" & ")")
FormNode.Expanded = True
Set rs = CurrentDb().OpenRecordset("select * from [tblrawmtlclass]
order
by [RawMtlClassName]")
Do While Not rs.EOF
sProductGroupName = rs("RawMtlClassName")
sProductGroupKey = "g" & rs("RawMtlClassName")
Set FormNode = .Nodes.Add("Root", tvwChild, sProductGroupKey,
sProductGroupName)
FormNode.Expanded = False
rs.MoveNext
Loop
Set rs = CurrentDb().OpenRecordset("select * from [qryrawmtlcategories]
order by [rawmtlclassname]")
Do While Not rs.EOF
sProductName = rs("rawmtlnature")
sProductId = "p" & rs("categorycode")
sParentId = "g" & rs("RawMtlClassName")
Set FormNode = .Nodes.Add(sParentId, tvwChild, sProductId,
sProductName)
FormNode.Expanded = False
rs.MoveNext
Loop
Set rs = CurrentDb().OpenRecordset("select * from
[qrytestrawmtlusage]")
Do While Not rs.EOF
sProductName = rs("SunCode") & " (" & rs("commonname") & ")"
sProductId = "p" & rs("SunCode")
sParentId = "p" & rs("catid")
If sParentId = "0NA" Then sParentId = "g" & rs("catid")
Set FormNode = .Nodes.Add(sParentId, tvwChild, sProductId,
sProductName)
FormNode.Expanded = True
If rs("coremtl?") = True Then
FormNode.ForeColor = 32768
FormNode.Bold = True
End If
If rs("coremtl?") = False Then
FormNode.ForeColor = vbRed
FormNode.Bold = False
End If
rs.MoveNext
Loop
End With
If Not rs Is Nothing Then rs.close
Set rs = Nothing
End Sub
I attempted to use your code. I placed an unbound text box into the form,
named it txtNodetext. Then I used the code you provided, and could not
get
the value to show up in the text box.
Thanks in advance for your help.
billmahon said:
and want to be able to change the font color of items in the tree based
on
certain criteria. Also, I would like to display information about the
item
highlighted on the tree control onto another part of the form by passing
the
value of the item on the tree control into the forms query. Can anyone
help?