CAnnot add record(s); primary key for table 'table1' not in recordset

I have table1 is a history table which contains fields primarykey, customerid, month, year, and other fields for the period
table2 contains customer info of 'a' given month/year

I want to 'update' table2 information to to table1.  

So

I  created query1, which contains all fields of table1, with criteria month and year set to the month and year I want to update.

I created query2, which has table1 left join with query1.

If query2 is a select query and I include primary of table1, then the query is fine and updatable.

However, if I made query2 an update query then I get the error message 'Cannot add record(s); primary key for table 'table1' not in recordset'.  I can't include primary key for table 'table1' because it's an update query.

Help?
jezsunAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LambersonSoftware EngineerCommented:
Can you post your queries?


Bob
0
harfangCommented:
Maybe there is some confusion...

1) Although I think you got that right: you can run an update query (execute) by double-clicking it or using the [!] button. You can also open an update query *as* select query if you use the normal "open query" button from the left of the toolbar, from design mode.

2) In datasheet view of a LEFT JOIN query, you can do several things: update data, auto-insert data in the right-side table, append new rows to the left-side table, etc. In action queries, you do only one thing at a time.

So:

* make two copies of your query
* in copy one, the UPDATE query, set the join to INNER JOIN, to update information from matching fields.
* in copy two, change to APPEND query and add the criteriy under "query1.keyfield" to Null. This will select only unmatched records, e.g. *new* records.

So you will be able to update in two steps: update matching records and append new records.

Hope this helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.