if primarykey value exists, bring up record

Ross Hurrell

Registered User.
Local time
Today, 16:07
Joined
Nov 17, 2006
Messages
11
Hello

I am trying to figure out how to make my database check to see if the primary key value is a duplicate of anything ive entered previously and if yes, for my database to bring up that record instead of adding a new record.

I know how to do bring up records using a separate combobox (find) but I cant seem to do it using the primary key field itself.

Many thanks in advance.
 
If you attempt to save a duplicate PK, Access with stop you. The error message may not be what you want, though.

You could capture the data in an unbound text box then use DCount() to count the number of existing occurances of that value in the PK field. 0 tells you it's a new value, 1 says it exists already. Use this in an If..Then statement to open the existing record or a new record.

Mind you, I wouldn't let users choose their own PK...
 

Users who are viewing this thread

Back
Top Bottom