Multi-select list boxes

  • Thread starter Thread starter cd
  • Start date Start date
C

cd

With a multi-select list box, do you need additional code
to store the multiple selections in the bound field or is
that possible at all? i.e., I set a text box to Multi-
select-simple and set the Control source to the field in
my table. If I select one value from the list it is stored
in the table, but if I select more than one value nothing
is stored. I realize that this implies we may not have a
normalized database but it's the best solution for our
purposes. I appreciate the assistance if someone as some
ideas.
 
Multi-Select ListBox *always* has Null Value so if you bind a Field to the
Multi-Select ListBox, you always get Null.

You will ned to use the "ItemsSelected" Property of the ListBox and code to
manipulate the selections in a list (comma separated, perhaps).

The code (to create the comma-separated list) should be something like:

****Untested****
Dim strList As String
Dim varItem As Variant

strList = ""
For Each varItem In Me.ListBoxName.ItemsSelected
strList = Me.ListBoxName.ItemData(varItem) & ","
Next varItem

If (Len(strList) > 0) Then
strList = Left(strList, Len(strList) - 1)
End If
****Code ends****

(Note: this is NOT the way I usually store data but you are aware of the
unnormalised problem)

HTH
Van T. Dinh
MVP (Access)
 
Back
Top