I have a module that runs when I check a checkbox that adds the existing record to a second table (1-1 relationship). It works just fine except that when I return to the master form, there is a new blank record that has been added after the one that I checked the box for. Any ideas why this is happening? Here is the code (a converted macro):
Function mcrAddApplicant()
On Error GoTo mcrAddApplicant_Err
DoCmd.OpenForm "frmApplicants", acNormal, "", "", acEdit, acNormal
DoCmd.GoToControl "ApplID"
DoCmd.FindRecord Forms!frmContacts!ContactID, acEntire, False, , False, acCurrent, True
If (Forms!frmContacts.ContactID <> Forms!frmApplicants.ApplID) Then
DoCmd.GoToRecord acForm, "frmApplicants", acNewRec
Forms!frmApplicants!ApplID = Forms!frmContacts!ContactID
DoCmd.Requery ""
DoCmd.GoToControl "ApplID"
DoCmd.FindRecord Forms!frmContacts!ContactID, acEntire, False, , False, acCurrent, True
End If
DoCmd.Close acForm, "frmContacts"
mcrAddApplicant_Exit:
Exit Function
mcrAddApplicant_Err:
MsgBox Error$
Resume mcrAddApplicant_Exit
End Function
Function mcrAddApplicant()
On Error GoTo mcrAddApplicant_Err
DoCmd.OpenForm "frmApplicants", acNormal, "", "", acEdit, acNormal
DoCmd.GoToControl "ApplID"
DoCmd.FindRecord Forms!frmContacts!ContactID, acEntire, False, , False, acCurrent, True
If (Forms!frmContacts.ContactID <> Forms!frmApplicants.ApplID) Then
DoCmd.GoToRecord acForm, "frmApplicants", acNewRec
Forms!frmApplicants!ApplID = Forms!frmContacts!ContactID
DoCmd.Requery ""
DoCmd.GoToControl "ApplID"
DoCmd.FindRecord Forms!frmContacts!ContactID, acEntire, False, , False, acCurrent, True
End If
DoCmd.Close acForm, "frmContacts"
mcrAddApplicant_Exit:
Exit Function
mcrAddApplicant_Err:
MsgBox Error$
Resume mcrAddApplicant_Exit
End Function