Reputation: 3239
I have a listbox called "lbItems" which is set to the RowSource property of "Table/query". I have an VBA statement which runs a query that selects "lineItem" from a table and this populates the listbox with the lineItems as seen below:
Me.lbItems.RowSource = "SELECT lineItem FROM Table1"
This doesn't give me any information about the lineItems however, that is found in the field "description". I want to use an VBA statement which runs an SQL query like this:
Me.lbItems.RowSource = "SELECT lineItem, Description FROM Table1"
I would like the above statement to populate my listbox with the lineItem, and right beside it, the description with a pipe "|" character in between.
This is the problem though. If you choose a different RowSource for the listbox, then you are able to concatenate strings and put whatever you would like as a list item which is what I want to do. But, with RowSource set to table/query, I can only use queries to set the list items.
Question 1: Is there any way to mix both of the above methods together? So to combine SQL statements and my own operations to populate the listbox?
Question 2: If there isn't a way to do what was asked in Question 1, can I select more than 1 field with my SQL statement and set BOTH of those fields to the list item?
Upvotes: 1
Views: 545
Reputation: 442
This is possible, you just need to configure the listbox for this. Under the Property Sheet in the Access form for the listbox change the following:
Upvotes: 1