I have a main form (Main Admin Book) that has several fields where users enter 'degrees' for personnel. I want to be able to have a pop up form where they can select multiple degrees and have those degrees then sent to the textbox when the pop up form closes.
Table: CTU Info
Field & TextBox name=CTU PI
MultiSelect ListBox: DegreesLB
I found the following code on this site (from Richard?) and have used it as a starting point and it does 'insert' the values into the base table,but it also creates a new record each time, when I need it to 'Update' the current record instead. I have tried to work with the CTU ID=CTU ID from main form, but haven't gotten it to work... Any ideas?
Private Sub Form_Close()
'if there is more than one degree selected then merge the two together and then save them in the database
Dim i As Integer
Dim textvalues As String
For i = 0 To DegreesLB.ItemsSelected.Count - 1
If DegreesLB.Selected(i) Then textvalues = textvalues + DegreesLB.Column(0, i) & ","
End If
Next
CurrentDb.Execute "INSERT INTO [CTU Info] ([CTU PI Degree]) VALUES ('" & textvalues & "');"
End Sub
Table: CTU Info
Field & TextBox name=CTU PI
MultiSelect ListBox: DegreesLB
I found the following code on this site (from Richard?) and have used it as a starting point and it does 'insert' the values into the base table,but it also creates a new record each time, when I need it to 'Update' the current record instead. I have tried to work with the CTU ID=CTU ID from main form, but haven't gotten it to work... Any ideas?
Private Sub Form_Close()
'if there is more than one degree selected then merge the two together and then save them in the database
Dim i As Integer
Dim textvalues As String
For i = 0 To DegreesLB.ItemsSelected.Count - 1
If DegreesLB.Selected(i) Then textvalues = textvalues + DegreesLB.Column(0, i) & ","
End If
Next
CurrentDb.Execute "INSERT INTO [CTU Info] ([CTU PI Degree]) VALUES ('" & textvalues & "');"
End Sub