Try this code :
Code:
Dim strSQL As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
strSQL = "SELECT * FROM tblPersons" & _
" WHERE FirstName = '" & Me!ctrlFirstName & _
"' AND LastName = '" & Me!ctrlLastName & _
"' AND DateOfBirth = '" & Me!ctrlDateOfBirth & "
Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
If Not rst.EOF Then
If MsgBox("Person " & Me!ctrlFirstName & " and " _
& vbCrLf & "with " & Me!ctrlLastName & "" _
& vbCrLf & "and date of birth " & Me!ctrlDateOfBirth & " allready exists" _
& vbCrLf & "Click NO to cancel", _
vbCritical + vbYesNo + vbDefaultButton2) = vbNo Then
Me.Undo
Exit Sub
End If
End If
'If no match, code to create your new record below.