multiselect on form convert to table

R

RTimberlake

After setting up a list box as multi select--how do I get the information
that has been choosen to show up on the table that has been created?
Access is a bear to figure out. Thank you for your help.
 
A

Arvin Meyer

Relational database normalization rules do not permit storing mutiple values
in a single field. So the right answer is, you don't. You can force muliple
values in a text box with code like this in the click event of the list box:

Dim varItem As Variant
Dim strList As String

With Me!lstElevation
If .MultiSelect = 0 Then
Me!txtSelected = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & ","
Next varItem
If strList <> "" Then
strList = Left$(strList, Len(strList) - 1)
End If
Me.txtSelected = strList
End If

End With

While txtSelected above could be bound to a field in the underlying table,
it is not. The code above is used to build an IN clause for a Select
statement.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
L

Larry Daugherty

You need to index through the items in the listbox and take action on
those which are selected ..

Aircode:

with me!listbox
For i = 0 to listbox.count-1
If .selected then
do something
end if
next i
end with

Look in Help for Selected and for Listbox properties

I'm concerned that you seem to want to create a new table and copy
data to it. That's not a good thing to do unless there's no other way
to achieve your objective. There usually is another way.

HTH
 
Top