Hello everyone!!! I'm a new poster here. Can somebody help me with my project. My listview is not working. :( I need to search a person's name using his/her lastname and firstname and display all the people with the same lastname or firstname and those data will display in the listview. the problem is, my listview is not working. it says something like this "invalid property value" and higlighten a part of my code (lst.SubItems(1) = RS!Firstname). here is my code. I hope you can help me. :'(
Private Sub txtsearch_KeyDown(KeyCode As Integer, Shift As Integer)
Dim str As String
Dim lst As ListItem
If KeyCode = 13 Then
Set RS = New Recordset
str = "select * from tblrecords where Lastname+' '+Firstname like '" & txtsearch.Text & "'"
RS.Open str, cn, adOpenDynamic, adLockOptimistic
lsvwed.ListItems.Clear
If RS.RecordCount > 0 Then
RS.MoveFirst
While Not RS.EOF()
With lsvwed
Set lst = .ListItems.Add(, , (RS!Lastname))
lst.SubItems(1) = RS!Firstname
lst.SubItems(2) = RS!Middlename
lst.SubItems(3) = RS!Address
lst.SubItems(4) = RS!Age
End With
RS.MoveNext
Wend
End If
If RS.EOF Then
MsgBox "File Not Found!", vbExclamation
If RS.State = adStateOpen Then RS.Close
Set RS = Nothing
End If
End If
End Sub