manrique83
Programmer
I have this form that updates a table once the user has tabbed to the end of the form and on to a new one.
The problem comes when I try and add the data from a multi-select listbox to the field in the table. Instead of adding the data in the same record, it adds a new record with only the chosen options from that listbox and nothing else, can someone help?
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim db As DAO.Database
Dim ctl1 As Control
Dim varItm As Variant
Dim myStr As String
Dim strSQL As String
Set ctl1 = Me.InvestHistory
For Each varItm In ctl1.ItemsSelected
myStr = myStr & ctl1.ItemData(varItm) & " ,"
Next varItm
myStr = Left(myStr, Len(myStr) - 2)
strSQL = "Insert Into tbl17a3(invHistory) Values ('" & myStr & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End Sub
The problem comes when I try and add the data from a multi-select listbox to the field in the table. Instead of adding the data in the same record, it adds a new record with only the chosen options from that listbox and nothing else, can someone help?
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim db As DAO.Database
Dim ctl1 As Control
Dim varItm As Variant
Dim myStr As String
Dim strSQL As String
Set ctl1 = Me.InvestHistory
For Each varItm In ctl1.ItemsSelected
myStr = myStr & ctl1.ItemData(varItm) & " ,"
Next varItm
myStr = Left(myStr, Len(myStr) - 2)
strSQL = "Insert Into tbl17a3(invHistory) Values ('" & myStr & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End Sub