List View Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AjGrace
    New Member
    • Jul 2007
    • 7

    List View Error

    Guys.. I know that this is so easy but I can't figure it out why List View Display an False text instead of the Data in my Database my Code is this

    Private Sub Form_Load()

    ListView2.ListI tems.Clear

    Call OpenConn
    Call OpenRs

    rs.Source = "Select * from Employee"
    rs.Open

    If rs.RecordCount > 0 Then

    Do While Not rs.EOF

    Set List = ListView2.ListI tems.Add(, , rs![Employee_No])
    List = List.SubItems(1 ) = rs![Emp_Fname]
    List = List.SubItems(2 ) = rs![Emp_Mname]
    List = List.SubItems(3 ) = rs![Emp_Lname]
    List = List.SubItems(4 ) = rs![Emp_Age]
    List = List.SubItems(5 ) = rs![Emp_department]
    rs.MoveNext
    Loop

    End If



    Call CloseRs
    Call closeConn
    End Sub

    I hope somebody will help me to figure it out.. thanks in advance...
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Originally posted by AjGrace
    Guys.. I know that this is so easy but I can't figure it out why List View Display an False text instead of the Data in my Database my Code is this

    Private Sub Form_Load()

    ListView2.ListI tems.Clear

    Call OpenConn
    Call OpenRs

    rs.Source = "Select * from Employee"
    rs.Open

    If rs.RecordCount > 0 Then

    Do While Not rs.EOF

    Set List = ListView2.ListI tems.Add(, , rs![Employee_No])
    List = List.SubItems(1 ) = rs![Emp_Fname]
    List = List.SubItems(2 ) = rs![Emp_Mname]
    List = List.SubItems(3 ) = rs![Emp_Lname]
    List = List.SubItems(4 ) = rs![Emp_Age]
    List = List.SubItems(5 ) = rs![Emp_department]
    rs.MoveNext
    Loop

    End If



    Call CloseRs
    Call closeConn
    End Sub

    I hope somebody will help me to figure it out.. thanks in advance...


    Private Sub Form_Load()
    Dim List as listitem
    ListView2.ListI tems.Clear
    Call OpenConn
    Call OpenRs
    rs.Source = "Select * from Employee"
    rs.Open
    If rs.RecordCount > 0 Then
    Do While Not rs.EOF
    Set List = ListView2.ListI tems.Add(, , rs![Employee_No])
    List = List.SubItems(1 ) = rs![Emp_Fname]
    List = List.SubItems(2 ) = rs![Emp_Mname]
    List = List.SubItems(3 ) = rs![Emp_Lname]
    List = List.SubItems(4 ) = rs![Emp_Age]
    List = List.SubItems(5 ) = rs![Emp_department]
    rs.MoveNext
    Loop
    End If
    Call CloseRs
    Call closeConn
    End Sub


    datatype of 'List' should be Listitem
    and check it contain 5 column

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Shouldn't the "List =" be removed from all those lines? In other words, rather than
      List = List.SubItems(2 ) = rs![Emp_Mname]
      I would have expected to see something like
      List.SubItems(2 ) = rs![Emp_Mname]
      However, I don't have much experience with listview.

      Comment

      • hariharanmca
        Top Contributor
        • Dec 2006
        • 1977

        #4
        Originally posted by Killer42
        Shouldn't the "List =" be removed from all those lines? In other words, rather than
        List = List.SubItems(2 ) = rs![Emp_Mname]
        I would have expected to see something like
        List.SubItems(2 ) = rs![Emp_Mname]
        However, I don't have much experience with listview.
        Of-course, you are correct (I am sorry, I never watch it).

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by hariharanmca
          Of-course, you are correct (I am sorry, I never watch it).
          It's always the sneaky little ones like that which slip through. :)

          In retrospect, I'm pretty sure that would be the source of the "False" - it's performing a comparison between a listbox item and a database field, and assigning the result to the subitem.

          Comment

          Working...