I have vb form that accepts input from user,search in database(database acess) and displays matching records if any in the listview .The problem is that the search query will display only one matching record even if there are many matching records
.anyone please help
Dim xRecords As Integer
rs.MoveFirst 'change rs to whatever you have named your recordset selector
For xRecords = 1 To rs.RecordCount
''Do with this record returned what you need to...
Your problem is the rs(x) part. You can loop through records but not through fields...
Well you can, but that is a totally different issue which is quite complex. :)
What you need to do is to change your code to -
Dim li1 As ListItem
''Dim x As Integer
Do Until rs.EOF
Set li1 = LV1.ListItems.Add()
''For x = 1 To 7 Don't need this...
List.SubItems(1) = rs!FieldName1
List.SubItems(2) = rs!FieldName2
List.SubItems(3) = rs!FieldName3
Whats happening is that you will start with record one and add it to your listview coloumn by coloumn.
rs will then move to the next and so on adding each rows data to your listview.