Hello All!
I have a form where a person can create/enter a new training CodeID and select the PositionID's, from a listbox, that would need that particular training. All of my vba code works except the following part which is the loop:
What I am trying to do is transfer the information to a table. The problem I am having, is that when more than one PositionID is selected, it doesn't enter any of the information. I'd like the information to transfer as such:
CodeID / PositionID
1.12 / AP
1.12 / D
1.12 / SS
etc.
What am I doing wrong? Thanks for all the help!!
I have a form where a person can create/enter a new training CodeID and select the PositionID's, from a listbox, that would need that particular training. All of my vba code works except the following part which is the loop:
Code:
Private Sub cmdSaveandAdd_Click()
DoCmd.SetWarnings False
Dim i As Variant, lstChosen As String, StrInsert As String
For Each i In Me.List87.ItemsSelected
lstChosen = Me.List87.ItemData(i)
StrInsert = "INSERT INTO [Training per Position]([CodeID],[Position ID]) VALUES ('" & Me!txtCodeID & "','" & lstChosen & "')"
DoCmd.RunSQL StrInsert
Next i
DoCmd.SetWarnings True
What I am trying to do is transfer the information to a table. The problem I am having, is that when more than one PositionID is selected, it doesn't enter any of the information. I'd like the information to transfer as such:
CodeID / PositionID
1.12 / AP
1.12 / D
1.12 / SS
etc.
What am I doing wrong? Thanks for all the help!!
Last edited: