Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi-Select Property 2

Status
Not open for further replies.

Tracyice

Technical User
Mar 10, 2004
30
US
I have a list box which I have set the multi-select property to simple for. I am wondering if there is any way to store the multi-selected data in a table using VBA?
 
Hi!

In vba you access the selected items for a list box using the following code:

Dim varRow As Variant

For Each varRow In Me!YourListBox.ItemsSelected
Do your stuff here using Me!YourListBox.Column(0, varRow)
to get info from the first column in the selected row
Next varRow

Note the list box property may be Columns instead of Column, I can't remember off the top of my head.

hth


Jeff Bridgham
bridgham@purdue.edu
 
From the help file:
Dim varItm As Variant, intI As Integer
For Each varItm In ctl.ItemsSelected
For intI = 0 To ctl.ColumnCount - 1
Debug.Print ctl.Column(intI, varItm)
Next intI
Debug.Print
Next varItm
where ctl references your listbox

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV-
Thanks for your help. I used your suggestion, however, it now keeps what I select for each record. For exampe, if I choose option a and option b from my selection box for record 1, it remains selected for record 2. Similarly, if I change the selection in record 2 to c and b, it changes it for record 1. If I have a specific field in a table that I wish to store the data in, is that possible? Right now, it still does not appear to save the data anywhere. Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top