Dim db As DAO.Database
Set db = CurrentDb
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
' from listbox in popup form
Dim strTable1ID As String
Dim strfield1 As String
' from form in background
Dim strContactID As String
Dim strContactfield3 As String
Dim strWhere As String
'pick up data to be copied from form in background
strContactID = [Forms]![frm_Contacts_Mgt]![C_ID]
strContactfield3 = [Forms]![frm_Contacts_Mgt]![C_field3]
' get record ID for Table1
If Me!List_All_Contacts.ItemsSelected.Count = 0 Then Exit Sub
For Each varItem In Me!List_All_Contacts.ItemsSelected
strTable1ID = strTable1ID & Me!List_All_Contacts.Column(3, varItem) & ","
Next varItem
strTable1ID = Left$(strTable1ID, Len(strTable1ID) - 1)
' get field1 to copy to contactfield3
If Me!List_All_Contacts.ItemsSelected.Count = 0 Then Exit Sub
For Each varItem In Me!List_All_Contacts.ItemsSelected
strfield1 = strfield1 & Me!List_All_Contacts.Column(0, varItem) & ","
Next varItem
strfield1 = Left$(strfield1, Len(strfield1) - 1)
' open contacts table to copy in field1 from table1
Set rst2 = db.OpenRecordset("tbl_Contacts", dbOpenDynaset)
With rst2
.FindFirst "C_ID = " & strContactID
If Not .NoMatch Then
.Edit
!C_field3 = strfield1
.Update
End If
End With
' open table 1 to copy field3 from the contact table
Set rst1 = db.OpenRecordset("tbl_Table1", dbOpenDynaset)
With rst1
.FindFirst "Table1_ID = " & strTable1ID
If Not .NoMatch Then
.Edit
!Field1 = strContactfield3
.Update
End If
End With
Me!List_All_Contacts.Requery
Forms.frm_Contacts_Mgt.Requery
Set db = Nothing
Set rst1 = Nothing
Set rst2 = Nothing