concatenate multi list box selections

batwings

Registered User.
Local time
Today, 23:43
Joined
Nov 4, 2007
Messages
40
Hi there

I am trying to use a list box and multi select from it as a source to enter data into a bound field in a table. I found what I thought was just what I need but I keep getting error 424 object required!

The list box is on a form bound to the field [comments] that I want to update.

The comments should be in the form of :-

comment1, comment2, comment3 and so on, depending on how many comments I select from the list box.

I have already added about 10 comments to the Rowsource of the listbox.


Code:
Private Sub cmdStoreAllSelections_Click()
Dim SelectedValues, item

For Each item In lstItems.ItemsSelected
    If SelectedValues > "" Then
        SelectedValues = SelectedValues & "," & lstItems.ItemData(item)
    Else
        SelectedValues = lstItems.ItemData(item)
    End If
Next item
Me!CompoundValue = SelectedValues
End Sub


Thanks again

Batwings
 
I found what I thought was just what I need but I keep getting error 424 object required!
I wonder if the problem might lie within the DIM statement...
Code:
Private Sub cmdStoreAllSelections_Click()
Dim SelectedValues, item [color=red]<----- Are you assigning a variable here??
e.g. - (Dim item AS "something"??)[/color]
But, the problem might not be there either. It might be in the code. ItemsSelected is a collection (I think), but I don't think you can assign a variable, or any entity for that matter, to the list box when sifting through your selections. I think you have to refer to the actual "indexed" item, in terms of the column and row in the listbox "list of values".

Have you seen Lister's Multi-Select List Box example???
 

Users who are viewing this thread

Back
Top Bottom