Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TreeView Code Error

Status
Not open for further replies.

rann

Programmer
Sep 13, 2001
86
US
Hi,
I am using the following code to fill a treeview but i am getting element not found do any one of you know why.(Error line# indicated by ***)

Dim strKey As String
Dim strCurr As String
Dim sSQL As String
Dim SQL As String
Dim CN As ADODB.Connection, RS As ADODB.Recordset

Set CN = CurrentProject.Connection
Set RS = New ADODB.Recordset
Me.axTreeView.Nodes.Clear
SQL = "SELECT DISTINCT [Curriculam Details].year,[Curriculam Details].[FacultyID#] FROM [Curriculam Details] WHERE ((([Curriculam Details].Year) Is Not Null) And (([Curriculam Details].[FacultyID#]) = " & Me.lstTest & ")) ORDER BY [Curriculam Details].year;"


sSQL = "SELECT DISTINCT [Curriculam Details].[CurriculamID#], [Curriculam Details].[FacultyID#], [Individual Course Details].[Year], [Individual Course Details].[Term], [Degree council].[Course#], [Degree council].[Course_Title]"
sSQL = sSQL & " FROM ([Curriculam Details] INNER JOIN [Individual Course Details] ON [Curriculam Details].IndividualCourseID = [Individual Course Details].[CourseID#]) INNER JOIN [Degree council] ON [Individual Course Details].[DegreeCourseID#] = [Degree council].[DegreeCourseID#]"
sSQL = sSQL & " WHERE ((([Curriculam Details].[FacultyID#]) = " & Me.lstTest & ") And (([Individual Course Details].Year) Is Not Null) And (([Individual Course Details].Term) Is Not Null)) ORDER BY [Individual Course Details].year;"


RS.Open SQL, CN, adOpenForwardOnly
Do Until RS.EOF
strKey = StrConv("o" & RS![Year], vbLowerCase)
Me!axTreeView.Nodes.Add , , strKey, RS!Year
RS.MoveNext
Loop
RS.close


RS.Open sSQL, CN, adOpenForwardOnly
Do Until RS.EOF
strKey = StrConv("p" & RS![CurriculamID#], vbLowerCase)
strCurr = StrConv(strKey & "o" & RS![Year], vbLowerCase)
Me!axTreeView.Nodes.Add strKey, tvwChild, strCurr, RS!Term '***
RS.MoveNext
Loop


RS.close
CN.close
Set CN = Nothing
Set RS = Nothing

Any help will be appreciated.
Thanks,
ran
 
Because it cant find a match for tvwchild

you add the parents with these lines
strKey = StrConv("o" & RS![Year], vbLowerCase
Me!axTreeView.Nodes.Add , , strKey, RS!Year

then try to add the child with these lines

strKey = StrConv("p" & RS![CurriculamID#], vbLowerCase)
strCurr = StrConv(strKey & "o" & RS![Year], vbLowerCase)
Me!axTreeView.Nodes.Add strKey, tvwChild, strCurr, RS!Term '***

I think if you reverse it to read
Me!axTreeView.Nodes.Add strcurr, tvwChild, strkey, RS!Term
it may do it
good luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top