Multiple Values Output to Separate Text Box

JamesEd83

New Member
Joined
Jan 28, 2014
Messages
33
Ok, here's a screenshot of what I want to accomplish

https://imgur.com/a/nihST

When I choose multiple options, the immediate window lists all of those options from column 1 in the drop down menu, separated by a comma. What I need is a separate box to list the column 2 items the same way. How do I auto populate the 'Loadblock Options Column 2' field based on what I have selected in the 'Loadblock Options' drop down menu? Also, not all of the selected options have values for column 2. Can Access ignore blanks?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
It depends on how you have it set up. And on a couple of assumptions.

I would write the code to loop through Column1, take all the selected values and combine them into the string (values separated by commas) for TextBox1. I'm going to assume you did this already.

I'll also make the assumption that Column1 and Column2 are from the same table, since they appear in the list together. And that the Column1 value is the bound column/value.

So, tweak the code you already have to:

[for each selected value in Column1:]

(you should already be doing this:
TextString1 = TextString1 & ", " & List.Column1.Value
[TextBox1] = TextString1

(look up the Column2 value in the source table using the same criteria you use in the list source)
(if the Column2 value is not blank, add it to the other text string/text box)
Item2Value = Nz(DLookUp("[Column2Value]","SourceTableName","Column1Value]='" & List.Column1.Value & "'"),"")
If item2Value <> "" Then
TextString2 = TextString2 & ", " & Item2Value
[TextBox2] = TextString2
End If

Hope this helps!
 
Upvote 0
That's awesome, thanks for responding!

I haven't written any code yet and I'm pretty new at Access, so I'm not 100% sure where to put the code. This text box is on a form that I will be using to generate a report, if that helps. Thanks again for your help!
 
Upvote 0
Yes, I'll start out by selecting some of the items in the list from a drop down, some of which have column 2 items. Any selected options with column 2 items need to go into a report which gets printed and given to our shop.
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top