use lbox recordset property w/ ado memory recordset?

use lbox recordset property w/ ado memory recordset?

Post by c2NvdHQgdy » Sun, 09 Nov 2008 23:10:01


i created an ado memory recordset (no disk-based persistent underlying table)
as follows

Dim r As New ADODB.Recordset
With r
.Fields.Append "Field1", adVarChar, 64
.Open
.Sort = "[Field1] ASC"
End With

then i added 2 records to r and verified that they were actually "there"
record 1: Field1="AAA"
record 2: Field1="BBB"

then i set the recordset property for a 1-column listbox whose parent form
is open, as follows

Set lbox.Recordset = r

now --
lbox.ListCount = 2, as it should
but
lbox has 2 blank lines,
lbox.ItemData(0) and lbox.ItemData(1) both return NULL
lbox.Column(0,0) and lbox.Column(0,1) both return NULL

is there any way to make this really work? thanks
 
 
 

use lbox recordset property w/ ado memory recordset?

Post by Michel Wal » Wed, 12 Nov 2008 00:04:16

Could work in VB6, but under an Access Forms, (else than ADP) are using DAO
recordsets, not ADO recordset. There is maybe a way to use your ADO
recordset, but I never used that way of doing it, using, instead, a callback
function to fill the list box.( http://www.yqcomputer.com/
as example).


Vanderghast, Access MVP

 
 
 

use lbox recordset property w/ ado memory recordset?

Post by c2NvdHQgdy » Wed, 12 Nov 2008 00:23:01

Thanks. Now I can stop my fruitless search for an easy answer.