Prevent duplicate record entry

maw230

somewhat competent
Local time
Today, 12:24
Joined
Dec 9, 2009
Messages
520
I've got a form used to enter information about store inspections. The tblInspection has: InspectionID (PK), InspecDate, and StoreNum.

InspecDate and StoreNum are always unique as there cannot be more than 1 inspection per day per store.

I dont want the user to be able to enter the same StoreNum and InspecDate for more than 1 record.

Should I have made a composite key out of InspecDate and StoreNum or is there another way to achieve this?
 
I would suggest using "AND" in a logical statement. On further thought, the use of "AND" was a bit more complicated than I originally thought. Essentially, where InspectDateStore1 = InspectDateStore2 AND Store1Num = Store2Num. When both conditions are true, you have a duplicate record.

Store2 stands for the value being entered into the form.
Store1 stands for an existing value already placed in a table.
 
Last edited:
Since InspecDate and StoreNum are always unique, in your table design view, Add one more field Date and keep the " Indexed " as < Yes (No Duplicates) > for the fields Date,InspecDate and StoreNum .

hope this help...
 

Users who are viewing this thread

Back
Top Bottom