I enter the form "frmContactsMain" in order to add a record using this code.
Code:
DoCmd.BrowseTo acBrowseToForm, "frmContactsMain", , , , acFormAdd
I enter the first and last name of the new contact. When leaving the last name field the event OnLostFocus searches for any records with those first and last names and displays those records in a new form frmChkDuplicates where Popup and Modal are set to yes.
If I want to continue to add, my "Continue Add" button it closes the frmChkDuplicates and I returned to the next field in frmContactsMain form.
My "Cancel Add" button is closes the form as well but I want to clear the fields (code not in the code below) and set the focus to the the first name. However, me.CfirstName.setfocus in bold below returns the error that I'm referring to a form that is closed.
Ignore the Tempvars below.
If it returns to the form with the ContinueAdd and allows me to continue at the next field, why doesn't it allow me to set focus.
Code:
Private Sub ContinueAdd_Click()
'TempVars!AddNewContact = "Yes"
DoCmd.CLOSE acForm, "frmChkDuplicates"
End Sub
Private Sub CancelAdd_Click()
'TempVars!AddNewContact = "NO"
DoCmd.CLOSE acForm, "frmChkDuplicates"
Me.CFirstName.SetFocus
End Sub