runtime error 3265

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nurikoAnna
    New Member
    • Nov 2008
    • 26

    runtime error 3265

    Code:
    
    Dim rsFaculty As New ADODB.Recordset
    Dim rsDepartment As New ADODB.Recordset
    Dim oCm As New ADODB.Command
     
    Private Sub Disconnect()
       connect.Close
    End Sub
     
     
     
    Private Sub Form_Load()
     
    'connect.Execute ("SELECT `t_faculty`.`FacultyFName`,`t_faculty`.`FacultyMI`,`t_faculty`.`FacultyLName`,`t_faculty`.`DepartmentID`,`t_department`.`Department`FROM `t_faculty`INNER JOIN `t_department` ON (`t_department`.`DepartmentID` = `t_faculty`.`DepartmentID`)")
    'Call connect
    'SQLconnection
    Call fillTree
     
     
     
     
    End Sub
     
     
    Sub fillTree()
     
    Dim sqlFaculty As String
    Dim sqlDepartment As String
    Dim nodeDepartment As Node
    Dim nodeFaculty As Node
     
     
    sqlDepartment = "SELECT `t_department`.`DepartmentID`FROM `t_department`"
    sqlFaculty = "SELECT `t_department`.`Department`,`t_faculty`.`FacultyFName`,`t_faculty`.`DepartmentID`FROM `t_faculty`INNER JOIN `t_department` ON (`t_department`.`DepartmentID` = `t_faculty`.`DepartmentID`)"
     
    tvTreeView.Nodes.Clear
    SQLconnection
    rsDepartment.Open sqlDepartment, connect, adOpenDynamic, adLockOptimistic
     
        Dim i As Integer, j As Integer
        With rsDepartment
     
            While Not .EOF
                   [U]Set nodeDepartment = tvTreeView.Nodes.Add(, , ![Department], ![Department], 1)[/U]
                nodeDepartment.Expanded = True
     
                 Set rsFaculty = oCm.Execute(, Array(![DepartmentID]))
                    While Not rsFaculty.EOF
                    Set nodeFaculty = tvTreeView.Nodes.Add(nodeDepartment.Index, tvwChild, , rsFaculty![FacultyFName], 1, 1)
                        j = j + 1
                        rsFaculty.MoveNext
                    Wend
                    nodeDepartment.Text = nodeDepartment.Text & "  [" & Trim(Str(j)) & "]"
                    j = 0
                i = i + 1
                .MoveNext
            Wend
        End With
        Disconnect
    End Sub
    above are my codes for to populate data in a list view...call data from the database..

    Currenty i am using MySQL as a database....


    I have a table t_department and another table is t_faculty...Wha t I like to do using a treeview....I want to display in the treeview the parent node as Department name then the child nodes are list of the Faculty names...

    and i always got an error :

    runtime error 3265

    item cannot be found in the collection corresponding to the requested name or cardinal at the underlined line above...

    please help.......
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Have you opend the ADODB connection object ?
    I can't find that in your code.

    Comment

    • MikeTheBike
      Recognized Expert Contributor
      • Jun 2007
      • 640

      #3
      Hi

      From you post it is this line producing the error

      Set nodeDepartment = tvTreeView.Node s.Add(, , ![Department], ![Department], 1)

      and the error suggests that [Department] field is not included in the recordset.

      From the SQl statment ie.
      sqlDepartment = "SELECT `t_department`. `DepartmentID`F ROM `t_department`"

      it would seem that that is indeed the case ([DepartmentID] is not [Department]) ???

      MTB

      Comment

      Working...