I'm using AfterUpdate on the Last Name field on a form to check for duplicated names and Undo if necessary, like this
How can I do the check if the user only enters a First Name?
Code:
Private Sub LastName_AfterUpdate()
Dim NewCustomer As String
Dim stLinkCriteria As String
NewCustomer = Me.FullName.Value
stLinkCriteria = "[FullName] = " & "'" & NewCustomer & "'"
If DCount("FullName", "qryClients", stLinkCriteria) > 0 Then
DoCmd.OpenForm "frmCheckName", acFormDS
End If
'Check for possible duplicate
If Me.FullName = DLookup("[FullName]", "qryClients", stLinkCriteria) Then
If MsgBox("This person, " & NewCustomer & ", is already in the database." _
& vbCr & vbCr & "Do you want to add another customer with this name?", vbYesNo) = vbNo Then
Me.Undo
DoCmd.Close acForm, "frmCheckName"
Else
DoCmd.Close acForm, "frmCheckName"
Exit Sub
End If
End If
End Sub
How can I do the check if the user only enters a First Name?