Newbie Help

  • Thread starter Thread starter tom
  • Start date Start date
T

tom

I have created a table for data entry purposes. I do not want user to
be able to enter duplicate dates. I have an autonumber field along
with the date field. To prevent duplicate dates from being entered I
have attempted to make both the autonumber and date field primary
keys. The autonumber filed works fine as a primary key. If I try to
add the date field as a primary key I get the message: "Index or
primary key can not contain a null value". I added an expression to
the default value in the date field =date() but it still doesn't work.

Am I going about this the wrong way? Please help. Thanks in advance!
 
tom said:
I have created a table for data entry purposes. I do not want user to
be able to enter duplicate dates. I have an autonumber field along
with the date field. To prevent duplicate dates from being entered I
have attempted to make both the autonumber and date field primary
keys. The autonumber filed works fine as a primary key. If I try to
add the date field as a primary key I get the message: "Index or
primary key can not contain a null value". I added an expression to
the default value in the date field =date() but it still doesn't work.

Am I going about this the wrong way? Please help. Thanks in advance!

Just create a unique index consisting of the date field. You can specify
uniqueness this way without having to involve the primary key.
 
In the defaults for the date field select:

Required - Yes
Index - Yes (No Duplicates)

The ID should be the only PK field.
 
Back
Top