Duplicate Entries

  • Thread starter Thread starter PeteEHP
  • Start date Start date
P

PeteEHP

I have a form that submits records in a table. now i want a message box
to appear when a user tries to submit a duplicate entry and the user
already exsists in the table.

table name : Id Cards
Form name: Id card form
Field name : Surname

so i will check against surname which is last name. So if a user tries
to submit the person twice it will show a message box and will not let
the user submit it?
thanks pete
 
I have a form that submits records in a table. now i want a message box
to appear when a user tries to submit a duplicate entry and the user
already exsists in the table.

table name : Id Cards
Form name: Id card form
Field name : Surname

so i will check against surname which is last name. So if a user tries
to submit the person twice it will show a message box and will not let
the user submit it?

ummm... and what will you do when the user is required to enter
information for Richard Jones and Mary Jones and the other Mary Jones?
Names are NOT unique.

Surely just a *warning*, not an absolute prohibition!

To do so, use the Form's BeforeUpdate event. Something like:

Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
If Not IsNull(DLookUp("[Surname]", "[ID Cards]", "[Surname] = " _
& Chr(34) & Me![Surname] & Chr(34)) Then
iAns = MsgBox(Me![Surname] & " already exists. Add anyway?", _
vbYesNo
If iAns = vbNo Then
Cancel = True ' don't add the record
Me.Undo ' erase the form
End If
End If
End Sub
 
HARLEM
IMPORT& EXPORT AND INTERNATIONAL TRADE LTD. CO.
N.KEMAL AVENUE LANGA BOSTANI STREET. NO32 AKSARAY
TURKEY
TEL& FAX:+9-0212-529-57-74
www.harlem.com.tr
(e-mail address removed)


find costumers for us and let us pay your comission
yours sincerely
nihat kaya


HARLEM WAS FOUNDED IN 1973. HARLEM COOMPANY IS A WHOLESELLER. WE HAVE LARGE
AMOUNT OF EXPORT CAPACITY. WE SELL:
• HOUSEHOLD
• KITCHENWARE
• ELECTRICAL APPLIANCE
• BATHWARE
• GARDENWARE
• TOYS
• GAS REGULATORS AND LPG HEATERS
• FLOOR & TABLE COVERING
 
Back
Top