Solved

Transfer multi selection from list box to text box

Posted on 2011-09-07
4
365 Views
Last Modified: 2012-05-12
Hello all

I have a list box (check style) in form45.

What i want to do it to be able to select, 1 or more selection from the list and when i click on the button, it will transfer all items selected from the list in my Form44.carrier_names (Textbox).

For ex: if i have only once selected in my list box, called "26". Then it will put "26" in my Form44.carrier_names (Textbox).

But is i have for example 3 selection, "08" "21" and "28". then it will transfert to the text box like this:
08
21
28



How can i do this please.

Thanks again for your help.


Form44.carrier_names = form45. List1

Open in new window


save-from-list.JPG
0
Comment
Question by:Wilder1626
  • 3
4 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 36499524
Set the Multiline property of the textbox to True. Then loop through the Listitems looking for those selected and then add them with vbCrLf at the end of each one.
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 36499538
Like so


Dim lngIndex As Long

For lngIndex = 0 To List1.ListCount - 1
    If List1.Selected(lngIndex) Then
        Text1.Text = Text1.Text & List1.List(lngIndex) & vbCrLf
    End If
Next

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 36499573
Thanks, this is perfect
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 36499577
Thanks. If you want to get rid of the last vbCrLf do

Text1.Text = Left$(Text1.Text, Len(Text1.Text) - 2)
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using Access 8 76
Adding to a VBA? 6 78
SQL VB connection works in one PC and doesn't in another 15 68
TT Auto Dashboard 13 95
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question