I am trying to add information into a table based on all selected items in a listbox.
tbl2Campaign_Trainers is the table
has three fields.
field1 = CampaignID
field2 = TrainerID
field3 = Active (yes/no field, this is used in a query subform later)
frmAssignCampaign is the form.
has a combobox and a listbox.
combobox - (lets you select the Trainer and bound to TrainerID)
listbox - (lets you select which campaigns are assigned to the trainer and bound to CampaignID)
The code is listed above. All that the code successfully does right now is adds the TrainerID to the table but keeps the CampaignID blank.Code:Private Sub Command20_Click() Dim conceptValue As String Dim strInsert As String Dim i As Variant For Each i In Me.lstCampaigns.ItemsSelected conceptValue = conceptValue & Me.lstCampaigns.ItemData(i) Next i strInsert = "INSERT INTO tbl2Campaign_Trainers(CampaignID) " & "VALUES('" & conceptValue & "');" DoCmd.RunSQL strInsert DoCmd.Close acForm, "frmAssignCampaign", acSaveNo End Sub
Having the information saved in multiple records is fine, actually preferred, as that will keep the option to only display active campaigns in the query subform later.
What in my code needs to be changed to make this successful?