Prevent duplicates - 4 fields together

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
 
A

Arvin Meyer [MVP]

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.
 
B

bhammer

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?
 
T

Tom van Stiphout

On Fri, 12 Dec 2008 17:19:01 -0800, bhammer

Actually, that's done in the Form_Error event.

-Tom.
Microsoft Access MVP
 

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