Add a multiple choice list on a form that creates new lines in the destination table (1 Viewer)

IshBuild

New member
Local time
Today, 21:56
Joined
Sep 20, 2017
Messages
6
Hi all,

I'm currently trying to add a multiple option box on a form for different pot sizes.

I know it's possible to use the multi-value combo box and the multiple choice when using a list box but 'm not entirely sure if it will generate two different lines on the destination table i'm sending the information to.

Does anyone have any good suggestions for a multiple selection box that would allow me to tick what I wanted and in succession create new lines in the table it's being saved to based on how many multiple choices were selected?

Hope that makes sense.

Many thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:56
Joined
May 7, 2009
Messages
19,229
you can using your listbox ItemsSelected property.
if you have a button there, insert the code
below to it's Click Event.

this will insert each selected items in the listbox.
all controls, tables and field names should be
replaced with the ones you have.


Code:
Private Sub Command2_Click()
    Dim varItem As Variant
    If Me.List0.ItemsSelected.Count <> 0 Then
        For Each varItem In Me.List0.ItemsSelected
            'Debug.Print varItem
            CurrentDb.Execute "Insert Into Table1 (field) SELECT " & Chr(34) & varItem & Chr(34)
        Next
    End If
            
End Sub
 

Users who are viewing this thread

Top Bottom