Use a collection to populate a listbox?

jal

Registered User.
Local time
Yesterday, 20:00
Joined
Mar 30, 2007
Messages
1,709
I love how VBA lets me load a whole table into a listbox using a SELECT query.

Currently I have a collection of invoices - invoice-objects - it's a weird mixture built from non-table sources. I need to display the collection on screen. (Due to some complicated dynamics furnished as special options for the user, I must use a collection, not just recordsets).

One way to do this, I suppose, is to load the invoice-objects into a temp table and then populate the listbox from the temp table.

Or is there a way to loop through my invoice-collection populating the listbox one row at a time?
 
You can set the RowSourceType property to 'Value List' and supply a semi-colon delimited string of data. You can construct such a list by ForEachNexting through your collection and concatenating the data from each object that you'd like to have appear in the list.
 
You can set the RowSourceType property to 'Value List' and supply a semi-colon delimited string of data. You can construct such a list by ForEachNexting through your collection and concatenating the data from each object that you'd like to have appear in the list.

I've heard of that, but I'm looking for a table structure (i.e., multicolumn structure). Isn't a value list geared to a single column?
 
No, a RowSourceType of Value List can display multiple columns. Here's an example...

Code:
   With Me.List0
      .RowSourceType = "Value List"
      .RowSource = "-1;You Bet;0;No Way"
      .ColumnWidths = "0;2"
      .ColumnCount = 2
   End With
 
No, a RowSourceType of Value List can display multiple columns. Here's an example...

Code:
   With Me.List0
      .RowSourceType = "Value List"
      .RowSource = "-1;You Bet;0;No Way"
      .ColumnWidths = "0;2"
      .ColumnCount = 2
   End With

Ahh....Brilliant. Thank you!
 

Users who are viewing this thread

Back
Top Bottom