Results 1 to 8 of 8
  1. #1
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150

    Append Query not ignoring primary key

    Okay I'm stumped, some functionality I'm sure used to work in my database now doesn't. Simple problem I have a table tblTempConnectors that I use as an interim step when importing data to tblConnectors. The data imports fine to tblTempConnectors but then I experience key violations on the import to tblConnectors because the ID numbers are already in use. I've tried creating an append query that doesn't include the [ID] field but still have the same problem. I don't care about the [ID] field they are both auto-numbers. How can I get it just to create new IDs? If it matters there are lots of gaps in the ID number sequence in tblConnectors as old data gets deleted from this table all the time. Hope that makes sense.

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    In an Append Query, you should not list any Autonumber fields. They will automatically be added when the records are added to the new table.
    So you do not want them to appear in the SELECT clause of your Append Query.

  3. #3
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    I haven't, This is my append query, the ID field isn't there.

    INSERT INTO tblConnectors ( Connector, EquipHarnessID, Type, Contacts, Gender, MateLimit )SELECT tblTempConnectors.Connector, tblTempConnectors.EquipHarnessID, tblTempConnectors.Type, tblTempConnectors.Contacts, tblTempConnectors.Gender, tblTempConnectors.MateLimitFROM tblTempConnectors;

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,743
    Robyn_P,
    You should use code tags when posting code---the hash/octothorpe (#)-- in the header of the reply area.

    Code:
    INSERT INTO tblConnectors ( Connector, EquipHarnessID, Type, Contacts,  Gender, MateLimit )
    SELECT tblTempConnectors.Connector,  tblTempConnectors.EquipHarnessID
    , tblTempConnectors.Type,  tblTempConnectors.Contacts
    , tblTempConnectors.Gender,  tblTempConnectors.MateLimitFROM tblTempConnectors;

  5. #5
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Sorry, none of the formatting of text wo0rks on the work computers for some reason, not even line breaks. Tried to update it on my phone but fiddly

  6. #6
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Update: Just realised when I try and add a new record manually it assigns it an ID that already exists even though it's meant to be an autonumber field. I'm googling for a solution, but if anyone knows what causes this it would be appreciated

  7. #7
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Okay, I think this thread has the solution, have to kick all the users out of the database before I can test it, but I think I have this covered. https://support.microsoft.com/en-gb/...a-new-record-i

  8. #8
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Yes a compact and repair fixed it, autonumber seeding had gone wrong somewhere.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Import Excel Access - Primary Key - Append table
    By mduplantis in forum Access
    Replies: 7
    Last Post: 10-03-2016, 10:39 AM
  2. Query ignoring criteria ONLY with parameters
    By Lluewhyn in forum Queries
    Replies: 2
    Last Post: 07-08-2016, 10:34 AM
  3. Append primary key record
    By WSelen1986 in forum Access
    Replies: 4
    Last Post: 12-10-2014, 12:02 PM
  4. Replies: 5
    Last Post: 07-06-2014, 10:18 AM
  5. Count Query w/o ignoring Nulls
    By Dulanic in forum Queries
    Replies: 3
    Last Post: 03-21-2012, 11:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums