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

Posted on 2004-11-08
Last Modified: 2012-08-14
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.  


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.

Question by:jezsun
    LVL 12

    Expert Comment

    Can you post your queries?

    LVL 58

    Accepted Solution

    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.


    * 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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now