Results 1 to 6 of 6
  1. #1
    DKP is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2014
    Posts
    7

    auto-number not used on insert

    I've got 2 tables A and B, where the structure of B is a copy of A. I use B as a temporary table to hold data while importing and once I know that the entire import is successful, I want to append B to A. My command for doing the append is as follows

    INSERT INTO A (two, three, four) SELECT two, three, four FROM B

    A and B have another field, one, which is an auto-number



    The append works fine, except that the 'one' values from B are also getting used for A. Does anyone know why A wouldn't be creating its own auto-number here given this syntax? It seems like this will lead to a duplicate values of 'one' in A.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Since the field is not included in the INSERT action, table A should generate its own values. Are you sure table A is not generating the values and they just happen to be the same as the ones in table B? Maybe remove the autonumber field from table B (apparently it is not needed) and see what happens.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    DKP is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2014
    Posts
    7
    It appears you're right. Even w/ the auto-number field removed from table B the 'one' field is still small. It's a little concerning because the original 'one' fields start at like 2500 and go to 20000, whereas the new ones are starting at around 0. Although it will take some time, the new fields will eventually cross the lower threshold of the old ones. Hope Access is smart enough to realize that and pick the next available value.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Is the One field value saved as a foreign key in a related table?

    Have you run Compact & Repair?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    DKP is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2014
    Posts
    7
    Actually, it appears that the original database developer didn't establish the relationship between those tables. I'll add it. Will that actually affect the way the auto-numbers are generated? I'll try to run compact & repair after I make those changes.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    No, relationships in the Relationship Builder are not required for a db to function.

    Why establish a relationship to a 'temp' table anyway?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Insert a Sequence Number in Query
    By am465 in forum Access
    Replies: 4
    Last Post: 11-12-2013, 02:52 PM
  2. Auto insert of value
    By uk123 in forum Programming
    Replies: 15
    Last Post: 10-29-2013, 12:23 PM
  3. Auto number automatically next number
    By wnicole in forum Access
    Replies: 3
    Last Post: 10-17-2013, 08:45 AM
  4. Replies: 3
    Last Post: 07-12-2013, 11:53 AM
  5. Insert x number of rows based on value
    By opopanax666 in forum Programming
    Replies: 4
    Last Post: 10-26-2010, 03:26 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