Prevent double records

I

Igor G.

I have first two columns in datasheet date and time.
How to prevent double entries in rows?

Example:
Date Time
--------------------
6.9.2006 10:30
6.9.2006 10:30

In this case i want message box with warning and empty field time.
Date can be same lake previous but time must be different.
Thanks!
 
J

J. Goddard

One way would be to make the Date and Time fields the primary key of the
table, and then trap the error (using code) that MS Access generates
when you try to add a duplicate.

Another way might be to use the After Update event of the Time to check
if that Date/Time combination is already in the table.

P.S. If your table fields or form controls are named "Date" or "Time",
I strongly suggest you change them - MS Access gets confused when you
use reserved words as field or control names.

John
 
B

Barry Gilbert

I would recommend storing the date and time in the same column. If you did
this, you could have a unique index on the table field which would prevent
duplicates. Storing the date and time together is a more robust way of doing
things, especially if you want to do calculations/comparisons based on date
and time.

Barry
 
I

Igor G.

I use another words for date and time, this is no problem.
Can you give me some code for suggested After Update event check?
Thanks!
 
Top