Selection from List Box to Text Box

T

Trini Gal

Hello,

I have a multi select list box, and I would like to have each selection the
user selects to show up in a text box separated by commas. I have read
enough and I know that its "Evil" to store more than one piece of data in a
field. This textbox is a notes/memo field, and is only being used as such.
I'm thinking that this would happen in the AfterUpdate Event of the List Box.

Does anyone have code that would help me out, or can someone point me in the
right direction?

Thanks.
 
T

Trini Gal

Douglas,

Thanks for answering my post. Where would I put this code? I'm not sure
what the code is doing, can you explain a little for future reference please?

Thanks.
 
D

Douglas J. Steele

Somehow you need to know when the user has finished selecting items from the
list box, so you may want to consider having a command button for that. If
that's the route you take, you'd put that code in the Click event of that
command button. Once you've figured out strValues, just plug it into the
text box on your form that's bound to the field in the table.

List boxes have a collection named ItemsSelected associated with them. As
the name implies, the collection contains one entry for each selected row in
the list box. The code is loop through all of the items in that collection
(using a variable varSelected), and determining what the value is for each
row (using the ItemData property of the list box. It concatenates each value
into the variable strValues (adding a comma and space after each entry).
Once it's finished concatenating the details for all of the selected rows,
it removes the final comma and space from the end of the string.
 
T

Trini Gal

Douglas,

Thank you so much for taking the time to explain to me the steps.

The code worked great. I only have one question. As I scan through my
records, the "spots" that were highlighted in the previous record stays
highlighted in the next one. Is there a way to unhighlight after I click on
my transfer button?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top