Prevent duplicates - 4 fields together

  • Thread starter Thread starter bhammer
  • Start date Start date
B

bhammer

tblInspections
----------------
InspectionID - Autonumber
AddressID - Foreign key
InspDate
Initials
InspTypeID - Foreign key

How can I prevent the user from entering a new Inspection record with the
same combination of Address, Date, Initials, and Type as another?

-Brad
 
Yes. Create a unique index on all 4 fields. In the table index dialog form,
create a name for the index, then add all 4 fields. (You can add up to 10
fields in a compound index) the at the bottom make sure the Unique property
is set to yes.
 
Arvin,

Ah, yes I forgot about the Index dialog. But how can I trap the event in a
form's BeforeUpdate event to display a less criptic dialog when the duplicate
is encountered?
 
On Fri, 12 Dec 2008 17:19:01 -0800, bhammer

Actually, that's done in the Form_Error event.

-Tom.
Microsoft Access MVP
 
Back
Top