Results 1 to 3 of 3
  1. #1
    abhi1214 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    2

    AutoNumber Primary key in Database starts jumping suddenly by thousand places .

    Click image for larger version. 

Name:	Records.JPG 
Views:	12 
Size:	18.4 KB 
ID:	17240

    Hi,
    The above image is of a table which I need to update according to a new data on daily basis. As you can see when I added two records at the last , the AutoNumber primary key of the table jumped by thousands . I have used the following query to update the table



    Code:
    db.Execute "INSERT INTO D_Counterparty (CPTY_ENTITY_ID,CPTY_DESC)"_ & "SELECT Ctpy_Entity_Id,Ctpy_Entity_Legal_Nm"_ & "FROM NewCU LEFT JOIN D_Counterparty ON D_Counterparty.CPTY_ENTITY_ID=NewCU.Ctpy_Entity_Id"
    I never changed the AutoNumber from incremental to random and I have also tried re-seeding it but had no success. Also when I inserted the sample values using a sample table ,the AutoNumber was working fine . Here's that query

    Code:
      db.Execute "INSERT INTO D_Counterparty (CPTY_ENTITY_ID,CPTY_DESC,) SELECT a,b, FROM sample"
    I did not use join in this query , is that making a problem ?

    I look forward to a reply as I think there should be some solution. Thank you in advance .

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    This is incorrect syntax.
    Code:
    SELECT a,b, FROM sample
    Autonumbers are unique --not sequential and not necessarily positive. You might find this useful.

    Good luck.

  3. #3
    abhi1214 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    2
    Ya that was an typing error . But dont you think this is because of the join statement which would not insert any record unless the condition is matched but would create a AutoNumber everytime and discard it ? I got this logic as combination of the link you posted and query that I wrote.

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

Similar Threads

  1. Primary Key Autonumber
    By data808 in forum Access
    Replies: 19
    Last Post: 07-15-2014, 06:51 AM
  2. Replies: 5
    Last Post: 07-07-2013, 08:49 PM
  3. Using AutoNumber primary key on sorted column
    By grkatz823 in forum Access
    Replies: 7
    Last Post: 03-04-2013, 03:47 PM
  4. Sequential autonumber primary key
    By JackCampion in forum Access
    Replies: 0
    Last Post: 09-17-2012, 05:07 PM
  5. Replies: 2
    Last Post: 04-30-2010, 09:43 AM

Tags for this Thread

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