1

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"

enter image description here

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?

1 Answer 1

1

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:

  • Change the "Column Count" to 2
  • Set "Column Widths" to 1";2"
  • Make sure "Bound Column" is 1
Sign up to request clarification or add additional context in comments.

1 Comment

All I had to do was change the column widths from 0";2" to 1":2" and it gave me what I wanted. Other than that perfect!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.