PK Null value

  • Thread starter Thread starter Colby
  • Start date Start date
C

Colby

What data type does the primary key have to be? I have my PK set to text and
it returns a null value error. It also says "PK cannot be a null value" when
i have the data type as Number (long integer). What am i doing wrong?
 
A primary key field's value is not allowed to be NULL because a primary key
always must have a unique value for every record. I'm guessing that you're
trying to set an exising field to primary key, and you already have records
in the table, and in at least one of those records that field's value is
NULL. You'll need to go to datasheet view of the table and put a unique
value in every one of the records for the field that you want to have be the
primary key, then after that is done you'll be able to make that field the
primary key.
 
Colby,

A primary key can be numeric OR text but it can't be empty (aka: Null). If
this primary key is of no use to you, meaning it doesn't have to be any
special set of letters or numbers, use Autonumber. Autonumber will fill in
a value for you.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
A primary key can be numeric OR text but it can't be empty (aka:
Null).

Nitpick:

Empty is not exactly the same as Null.

Empty could be a zero-length string (if that's allowed to be stored,
and, annoyingly, since A2003, allowing ZLS is the default for text
fields).

In a field that allows ZLS, Null could mean "nobody has even
bothered to decide what should be in this field -- it's completely
unknown" while the ZLS (empty) could mean "somebody checked this
record and stored a ZLS to show that there is no value for this
field."

One option to avoid the Null problem in a compound unique index is
simply to allow ZLS and set the default value to "".

But I'd never do that.

Of course, I'd also never use compound keys!

The point is that any field in a unique index has to have a default
value. Otherwise it could be Null and thus can't function as a
unique index.
 
Back
Top