Show Disconnected Recordset in ListBox

jal

Registered User.
Local time
Today, 12:03
Joined
Mar 30, 2007
Messages
1,709
I'm trying to display a disconnected recordset in a listbox. To debug this, I used this code to verify that all 162 records are present:

Do Until rs.EOF
Debug.Print rs("DisplayName")
rs.MoveNext
Loop

Immediately after the loop comes this code to put the recset into the listbox

LBprograms.ColumnHeads = True
LBprograms.ColumnCount = 2
LBprograms.ColumnWidths = "2in; 10in;"
Set Me.LBprograms.Recordset = rs

It's not throwing any errors. In fact, I can see the listbox gets populated with the 162 rows (a scroll bar appears, and the column names appear). But the two columns are blank in all rows (except for the first row where the two column names display). There is a vertical bar running all the way down between the two columns and I can scroll to the last row.
Here's how I created the disconnected recordset:

Dim rs As New ADODB.Recordset
rs.CursorLocation = adUseClient 'omitting this line didn't help
'create two columns
rs.Fields.Append "DisplayName", adLongVarChar, 400 'SIZE REQUIRED !!!
rs.Fields.Append "UninstallString", adLongVarChar, 2000
rs.Open

and then I have code that adds 162 new records, using a loop.


 
Why don't you put the query in the Row Source property?
This recordset was disconnected FROM THE START. Has nothing to do with a query, nothing to do with a database. It was populated by a loop, from scratch.
 

Users who are viewing this thread

Back
Top Bottom