Reputation: 445
What I am trying to accomplish is a single list box with two columns. In each column, results from a field will be displayed. Take this query for example:
SELECT FirstName, LastName FROM Names WHERE FirstName = 'Tom'
The list box would have two columns, with the first column holding all first names selected from the query. The second column would have all last names selected from the query, but each column would be matching. Ie. in the database, a "Tom A" record would not be mixed with a "Tom B" record when displayed in the list box columns.
I've tried searching before, but all I can find is using listbox.AddItem, which will not work in my case since I am querying a database to populate the listbox.
Upvotes: 3
Views: 5310
Reputation: 8402
Put that SQL in the RowSource property of the list box. Make sure your Column Count property is set to 2, and that the Column Width property is set to a value. Empty values or "0" will result in the column not being seen. So, your Column Widths property should be set to "2; 2" (without the quotes, and you can adjust those as necessary).
Upvotes: 5