Solved

Transfer multi selection from list box to text box

Posted on 2011-09-07
4
363 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now