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?
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.
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!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.