Message Box if Duplicate Customer Name

N

Nicholas

Hi

Dose anyone have a piece of code to help prevent the same
name getting entered in my Customers table

I have two fields 'FirstName' and 'LastName' I would like
a piece of code to attach to the after update event of
the 'LastName' field that basically checks if there is
another record with both the same 'LastName' and the
same 'FirstName' as the record that is just being created
in the Customers Detail form 'frmCustomerDetails'. I want
to still allow the user to enter a customer with the same
name but just flash up a message box that warns them a
person with the exact same name is already recorded in
the Customer details table 'tblCustomerDetails'.

If anyone can help thanks in advance

Private Sub LastName_AfterUpdate()

IF ???????????????

End Sub
 
K

Ken Snell

On the AfterUpdate event of the LastName control:

Private Sub LastName_AfterUpdate()
If DCount("*", "tblCustomerDetails", "LastName='" & [LastName] & _
"' And [FirstName]='" & [FirstName] & "'") > 0 Then
MsgBox "The database already contains a record for a person " & _
"with the same first and last names."
End If
End Sub
 
N

Nicholas

THANKS
-----Original Message-----
On the AfterUpdate event of the LastName control:

Private Sub LastName_AfterUpdate()
If DCount("*", "tblCustomerDetails", "LastName='" & [LastName] & _
"' And [FirstName]='" & [FirstName] & "'") > 0 Then
MsgBox "The database already contains a record for a person " & _
"with the same first and last names."
End If
End Sub


--

Ken Snell
<MS ACCESS MVP>

Hi

Dose anyone have a piece of code to help prevent the same
name getting entered in my Customers table

I have two fields 'FirstName' and 'LastName' I would like
a piece of code to attach to the after update event of
the 'LastName' field that basically checks if there is
another record with both the same 'LastName' and the
same 'FirstName' as the record that is just being created
in the Customers Detail form 'frmCustomerDetails'. I want
to still allow the user to enter a customer with the same
name but just flash up a message box that warns them a
person with the exact same name is already recorded in
the Customer details table 'tblCustomerDetails'.

If anyone can help thanks in advance

Private Sub LastName_AfterUpdate()

IF ???????????????

End Sub


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top