I have a form, frm_Main, with three subforms. One of the subforms, sfrm_Service, contains a multi select list box. This list box shows all the possible repairs that can be done on a particluar instrument. I want the user to be able to click all that is done. I also placed a command button, cmd_Add, on the main form to add the records. I am using the following code to add the records in the sfrm_Service list box but nothing happens. Please help.
Dim db As Database
Dim rec As Recordset
Dim varSelected As Variant
Set db = CurrentDb()
Set rec = db.OpenRecordset("tbl_Service")
'Add Records
For Each varSelected In Me!list_Service.ItemsSelected
rec.AddNew
rec("DeptService") = Me!list_Service.ItemData(varSelected)
rec.Update
Next varSelected
db.Close
Set db = Nothing
Dim db As Database
Dim rec As Recordset
Dim varSelected As Variant
Set db = CurrentDb()
Set rec = db.OpenRecordset("tbl_Service")
'Add Records
For Each varSelected In Me!list_Service.ItemsSelected
rec.AddNew
rec("DeptService") = Me!list_Service.ItemData(varSelected)
rec.Update
Next varSelected
db.Close
Set db = Nothing