I am trying to update subform fields when a field on the main form is changed. It works well with the first record in the multiple items subform I wish to update. However, I want it to add additional records to the subform when the field on the main form contains multiple values. The problem I'm running into here is that when I use .Form.Recordset.AddNew in the If/Then statements, all of the subforms in the form become locked. The error I am receiving is "Could not update; currently locked by another session on this machine." I've tried .Form.Recordset.Update, but it produces the same error along with a different error. I've also tried disabling locks in Access Options and all of my forms, but all of my forms' locks were already disabled and the AO tick box did not change anything. Here is the relevant code:
Code:
Private Sub ComBox_Change()
If [Field] Like "*Data1*" Then
Me!Subform.Form.Recordset.AddNew
Me!Subform.Form.Subfield = "Data1"
End If
If [Field] Like "*Data2*" Then
Me!Subform.Form.Recordset.AddNew
Me!Subform.Form.Subfield = "Data2"
End If
End Sub
I'm lost as to what to do now. I've been researching this for quite a while.