View Single Post
  #2  
Old April 14th, 2010, 03:11 AM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Do I have to set the primary key to include primary key fields?

On Tue, 13 Apr 2010 17:46:01 -0700, boooney
wrote:

I have read that "in a junction table, you need to set the primary key to
include the primary key fields from the other two tables. "


Well, it's a good idea, but it's not in fact obligatory.

If I do this, I keep getting the error message "the change you requested to
the table were not successful because they would create duplicate values in
the index, primary key, or relationship.


Sounds like you defined just one of the fields as the primary key, rather than
ctrl-clicking both fields and clicking the Key icon. Both foreign keys should
have the key icon next to them in table design view - not just one of them.

The only way I'm entering data is through a form based on a query which
automatically writes to all 3 tables (the junction and 2 parents) at once.


Generally a Very Bad Idea. Why not use the tools that Access provides - a form
based on one of the "one" side tables, and a subform based on the junction
table?

If I remove the primary keys in the junction tables, I no longer get the
error message. Am I going to regret this later?


Junction tables, plural? Are there more than one?

--

John W. Vinson [MVP]