4
Contributors
13
Replies
47
Views
4 Years
Discussion Span
Last Post by hannah_2
0

Make use of a loop...

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...

    rs.MoveNext
Next xRecords
0

use loop after search query

While rec.EOF = False
'write here what you wants (display records)
rec.MoveNext
wend

hope this helps you

0

AndreRet & rishif2 thanks for the help ...but inside the loop the list view is not working.

0

I am not able to post the code here.I made use of list view for displaying the records

0

Dim li1 As ListItem
Dim x As Integer
LV1.ListItems.Clear
Do Until rs.EOF
Set li1 = LV1.ListItems.Add()
For x = 1 To 7
List.SubItems(x) = rs(x)
Next x
rs.MoveNext
Loop

0

The list view doent display the matching records

0

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

LV1.ListItems.Clear

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
    ''etc...
''Next x
    rs.MoveNext
Loop

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.

0

List.SubItems(1) = rs!FieldName1 is throwing error

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.