Just a thought that may not fit what you are doing but.....
I often use the List View control to display results from a Select statement.
Fill the List view by looping through the recordset.
If you are just displaying records, it works great
I then have the user either dblclick the selected item or use a command button to load another form to display the details of that individual item should they want to edit that record.
Seems to be pretty efficient, but most of the time I am using it where each potential record has many fields. I only select a "summary" of the records and list them, then make a selection. So far the users seem to like this.
I use a connection string and open a connection instead of an ADODC control.
Simple version of the code:
Private Sub LoadList()
On Error GoTo fail
'fill the listview
Dim Item As ListItem, v As Variant, f As Field
sethead ' sub that sets the column headers
Do While Not adoPrimaryRS.EOF
For Each f In adoPrimaryRS.Fields
'get the field value
v = pffield(f)
If f.Name = "Something" Then
Set Item = LVRS.ListItems.Add(, , v)
Else
'rest are sub items
'somethingmay not have an associated IDNUM when dropped so
'check for that and set it to a default
If f.Name = "IDNUM" Then
If IsNull(v) Or v = "" Then v = "Empty Drop"
End If
Item.ListSubItems.Add , , v & ""
End If
Next
If LVRS.ListItems.Count > 100 Then
Dim l As Long
If l = LVRS.ListItems.Count Mod 100 = 0 Then DoEvents
End If
adoPrimaryRS.MoveNext
Loop
LVRS.Visible = True
colwidth 'set width of columns dynamically
Exit Sub
fail:
MsgBox Err.Description, vbExclamation
End Sub
don't foget this
Public Function pffield(ByVal f As Field) As Variant
'return value in recordset field ,converting any nulls to empty string
If IsNull(f.Value) Then
pffield = ""
Else
pffield = f.Value
End If
End Function
The next routine is a sub to clear the listview in the event you have too many records. I once filled a list view control with over 52,000 records (don't even ask!!!!) so I developed this to keep me out of trouble
Public Sub GetRidOfIt(ByVal f As Form)
'clear list view control
'if the listview contains too many records the app may lock on clear.
'If not locked, the process may take some time so indicate something is happening
'Experimentation on various old pc's lead me to the 300 record cut off, but newer
'pcs are so fast that a couple of thousand records could be cleared without
'a problem I would suspect
On Error GoTo fail
If f.LVRS.ListItems.Count > 300 Then
Dim Item As ListItem
Dim l As Long 'just a counter for display puposes
l = f.LVRS.ListItems.Count
For Each Item In f.LVRS.ListItems
Set Item = Nothing 'destroy the item
f.Status.SimpleText = "Record " & l & "has been removed."
l = l - 1 'count it down.
Next
Else
f.LVRS.ListItems.Clear
End If
Exit Sub
fail:
MsgBox Err.Description, vbExclamation
End Sub
There is a lot more to each form, but this should explain the basics.
if not let me know
Terry (cyberbiker)