Prevent double records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
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
 
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 use another words for date and time, this is no problem.
Can you give me some code for suggested After Update event check?
Thanks!
 

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

Back
Top