The problem with that code is that it is made to work only with one form. If you have another form opening like you do to check only, try this code out (I used your field names and form names.)
Before you do, you will have to have a primary key in the table (ContactID). Also, I use a macro to set the values of the Main form to the fields on the Check form in the instance where there is no duplicate. There is probably a better VBA way but I am not an expert programmer. The macro simply has two SetValue actions that set the value of the FirstName field on the Main form to equal the Text1 field of the Check form (and the same for LastName).
On Error GoTo Err_btnCheckDuplicates_Click
Dim FormName As String, SyncCriteria As String
Dim f As Object, rs As Object
Dim Response As Variant
' form name to be syncronized
FormName = "Check"
'Define the from object and recordset object for the Access form
Set f = Forms(FormName)
Set rs = f.RecordsetClone
' define the criteria used for the sync
SyncCriteria = "[FName1] = '" & Me![Text1] & "' And [LName1] = '" & Me![Text2] & "'"
' find the corresponding record in the Parts table
rs.FindFirst SyncCriteria
If rs.NoMatch = True Then
DoCmd.RunMacro "mcrNewContact"
Else
f.Bookmark = rs.Bookmark
Response = MsgBox("A record exists with that name. To use this record, simply press OK. To add a new record with that name, press CANCEL.", vbOKCancel)
If Response <> vbOK Then
DoCmd.RunMacro "mcrNewContact"
DoCmd.RunCommand acCmdSaveRecord
Else
DoCmd.OpenForm "Main", acNormal, , "[contactid] = forms![check]![contactid]", acFormEdit
DoCmd.GoToControl "FName1"
End If
End If
DoCmd.GoToControl "FName1"
DoCmd.Close acForm, "Main", acSaveYes
Exit_btnCheckDuplicates_Click:
Exit Sub
Err_btnCheckDuplicates_Click:
MsgBox Err.Number & " " & Err.Description
Resume Exit_btnCheckDuplicates_Click
joshuab@musician.org
joshuaweb.htmlplanet.com