multi-select listbox items to pass into textboxs

dgunbreakable

New member
Local time
Today, 13:24
Joined
Oct 13, 2014
Messages
7
I have an access project that I am working on and need to be able to select multiple items from a listbox and have the exact selections appear in a textbox on the same form. I have looked around and have not been able to find any code that works.

I have tried:

Me.user2 = Me.slct_auditor.Column(0, 1)
Me.user3 = Me.slct_auditor.Column(0, 2)
Me.user4 = Me.slct_auditor.Column(0, 3)
Me.user5 = Me.slct_auditor.Column(0, 4)
Me.user6 = Me.slct_auditor.Column(0, 5)
Me.user7 = Me.slct_auditor.Column(0, 6)
Me.user8 = Me.slct_auditor.Column(0, 7)

but when skipping the first item in the listbox it is still passed as into the textbox.

HELP please.

Thank you,
 
I don't see what I am looking for in that link. I was able to find the code below, but the description says its to move from listbox to listbox. I need to move each individually selected item into a textbox.

Private Sub cmdCopyItem_Click()
CopySelected Me
End Sub

Public Sub CopySelected(ByRef frm As Form)

Dim ctlSource As Control
Dim ctlDest As Control
Dim strItems As String
Dim intCurrentRow As Integer

Set ctlSource = frm!lstSource
Set ctlDest = frm!lstDestination

For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
strItems = strItems & ctlSource.Column(0, _
intCurrentRow) & ";"
End If
Next intCurrentRow

' Reset destination control's RowSource property.
ctlDest.RowSource = ""
ctlDest.RowSource = strItems

Set ctlSource = Nothing
Set ctlDest = Nothing

End Sub
 
you want to use the "selecteditems" property of the list box

for each varitem in mylistbox.selecteditems ... etc

it's fiddly getting the syntax correct though.


(and this is what namliam's link referenced)
 
Last edited:
atleast it shows you how to (properly) find those that are selected...

Once you have those that are selected, sending them anywhere should be a piece of cake.
 

Users who are viewing this thread

Back
Top Bottom