I am having a number of problems. I have a program which uses a number of different Treeview controls in a control array to display heirarchical data.
What I did was create two subs which are triggered in sequence. One to set up the root data, and one to set up the data that is in the branches.
Before this... I used seperate subs for each treeview, which needless to say created a lot of code that was essentially the same, wasted memory and space. BUT AT LEAST IT wORKED!
Now that I am using the control arrays I am having no end of trouble! First it was Invalid Object errors, then it was Type Mismatch errors. Can anyone look these over and tell me what the heck is wrong with them?
Thanks in advance,
Eiredrake
Oh... I am using DAO 3.1. With the DB object declared modularly in the form. The root is called first, then the branches
------------Begin Code----------
Private Sub mnuAptitudes_Click()
Dim strSQL As String
Call Hide_Sections(3)
strSQL = "SELECT * FROM [DL-SKILLS]"
Call Setup_Root(strSQL, trvSkills(0))
strSQL = "SELECT * FROM [DL-Concentrations]"
Call Setup_Branch(strSQL, "Concentration", trvSkills(0))
End Sub
Private Sub Setup_Root(RootSet As String, Target As Object)
Dim intCount As Integer
Dim rstDataSet As Object
Dim TempNode As Node
Target.Nodes.Clear
With DB
Set rstDataSet = DB.OpenRecordset(RootSet, dbOpenDynaset, dbReadOnly)
With Target
.Indentation = 25
.LineStyle = tvwRootLines
.Style = tvwTreelinesPlusMinusText
End With
If rstDataSet.RecordCount = 0 Then Exit Sub
With rstDataSet
.MoveLast
.MoveFirst
For intCount = 1 To rstDataSet.RecordCount
Set TempNode = Target.Nodes.Add(, , !Name, !Name)
.MoveNext
Next intCount
End With
End With
End Sub
Private Sub mnuAptitudes_Click()
Dim strSQL As String
Call Hide_Sections(3)
strSQL = "SELECT * FROM [DL-SKILLS]"
Call Setup_Root(strSQL, trvSkills(0))
strSQL = "SELECT * FROM [DL-Concentrations]"
Call Setup_Branch(strSQL, "Concentration", trvSkills(0))
End Sub
Private Sub Setup_Branch(BranchSet As String, Branchname As String, Target As Object)
Dim intCount As Integer
Dim rstDataSet As Object
Dim TempNode As Node
With DB
Set rstDataSet = DB.OpenRecordset(BranchSet, dbOpenDynaset, dbReadOnly)
With Target
.Indentation = 25
.LineStyle = tvwRootLines
.Style = tvwTreelinesPlusMinusText
End With
If rstDataSet.RecordCount = 0 Then Exit Sub
With rstDataSet
.MoveLast
.MoveFirst
For intCount = 1 To rstDataSet.RecordCount
Set TempNode = Target.Nodes.Add(!Name, tvwChild, , Chr(33) & Branchname)
'object.Add(relative, relationship, key, text, image, selectedimage)
.MoveNext
Next intCount
End With
End With
End Sub
