Populate listbox with disconnected recordset?

W

Webtechie

I have a spreadsheet which has several tables. I create a name and then
populate the listboxes on my userforms from these tables.

'Populate the listbox
'********************
lastRow = wks.Range("aq1").End(xlDown).Row
Set FoundRng = wks.Range("aq2:bg" & lastRow)

With FoundRng
.Name = "DataFoundTable"
End With
With frmValidate
.lstSearch.RowSource = "data!DataFoundTable"
End With

Now I need to move my data out of the workbook and into Access tables. I've
been studying, but I'm not seeing what to do with my listboxes from all the
books.

1) If I move my data to Access, do I need to bring the data back into Excel
to populate a listbox?

(Use .copyfromRecordset into a range and then use that range for the
listbox?)

2) Is it possible to populate a listbox from a disconnected recordset?

Thanks.

Tony
 
B

Bob Phillips

Don't use CopyRecordset, Use GetRows to put them into an array and then
populate the listbox from the array

ary = rs.GetRows
Listbox.List = ary
 
B

Bob Phillips

I should have mentioned that you need to transpose the array

ListBox1.List = Application.Transpose(ary)
 
W

Webtechie

An Important part of this I failed to mention is that my listboxes normally
have about three columns.
 
W

Webtechie

Bob,

Does this bring in multiple columns?

Tony

Bob Phillips said:
I should have mentioned that you need to transpose the array

ListBox1.List = Application.Transpose(ary)

--
__________________________________
HTH

Bob
 
B

Bob Phillips

Yes it does, just make sure that your listbox has the ColumnCount property
set.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top