P
Peter via AccessMonster.com
I have the following code to insert multiple select values from a listbox
into a table, but it is bombing out on the last SQL statement. Can someone
help me with this?
Thanks,
Peter
Private Sub Add2TblBtn_Click()
Dim frm As Form, ctl As Control
Dim varItm As Variant
Dim txtList, strSQL As String
Set frm = Forms!Form1
Set ctl = frm!ListBox1
For Each varItm In ctl.ItemsSelected
‘ I think the below is putting the multi select items in txtlist
txtList = txtList & "," & ctl.ItemData(varItm)
Next varItm
strSQL = "INSERT INTO CustListbox([cust_ID]),[SelectedItems]) SELECT " & Me.
ListBox1.Column(0) & "," ' & txtList & '","
DoCmd.RunSQL strSQL
into a table, but it is bombing out on the last SQL statement. Can someone
help me with this?
Thanks,
Peter
Private Sub Add2TblBtn_Click()
Dim frm As Form, ctl As Control
Dim varItm As Variant
Dim txtList, strSQL As String
Set frm = Forms!Form1
Set ctl = frm!ListBox1
For Each varItm In ctl.ItemsSelected
‘ I think the below is putting the multi select items in txtlist
txtList = txtList & "," & ctl.ItemData(varItm)
Next varItm
strSQL = "INSERT INTO CustListbox([cust_ID]),[SelectedItems]) SELECT " & Me.
ListBox1.Column(0) & "," ' & txtList & '","
DoCmd.RunSQL strSQL