Generating Primary Key

daved2424

Registered User.
Local time
Today, 21:01
Joined
Jun 28, 2001
Messages
20
I have three fields, One called Key, one called IS and one called BC. I want the table to automatically copy the number from the IS field to the Key field to be used as the primary key. However, this field does not always have a value, when this occurs I want it to take the value from the BC field. Is this possible?
 
A primary key always has to have a unique value.

I think that it would be better to just have an autonumber primary key, then manipulate and test the other fields as appropriate. Incrementing primary keys are very, very useful.

Absent some compelling cimcunstance, nothing else should be used.

For you case, the primary key can't be generated in the abstract, how are up creating records?
 
I agree with ilkhoutx.

From your description, you are trying to populate a field in hopes of eventually making the field your primary key.

This is doing it backwards.

If you don't already have a proper primary key defined/identified, it is too late now. Even if you created an autonumber field and tacked it onto your table, that won't cause the previously entered records to become populated with the key value.

I suspect you don't yet fully understand the implications of having a primary key. The "key" word is UNIQUENESS. And your description says that might be a problem.

Why? Because if your "preferred" source for this key is null more than once, it is not a proper candidate. Having a null in this position for some records means you have at least a few cases where the record's contents do not depend on that field. Which disqualifies it.
 
You could use something like below in an append query

iif(isnull([IS])=True,[BC],[IS])


But I do have to say that I agree with the above two posts.
 

Users who are viewing this thread

Back
Top Bottom