Results 1 to 4 of 4
  1. #1
    mparunk is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2015
    Posts
    1

    how to give Primary Key Increamet and decreament automatically?

    Hi ,
    I am new in ms access , I want make one database about office register. That is Have done . I gave primary key for auto increment serial number . That is working fine. Now problem is some times I want delete client name in between table .That is maybe first row or 5th row or anywhere . at the time the row deleted which is i was selected but the primary key is not update . for example I want delete 8th row . after deleting I not seen 8 in primary key place i have seen only ....,5,6,7,9,10...... etc. So please tell me how to give auto increment and decrement in the primary key......


    thanks


    regards
    Arunkumar M
    India.

    Sorry for my grammatical mistake....

  2. #2
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,421
    You cannot use Autonumbers this way. They do not have to be sequential and they are only for identifying a table row - it is not important that they increase or decrease sequentially. It is not important if there are gaps. In a multi-user database, you cannot even ensure there are no gaps when records are created. If you need them to be sequential, you need another way of creating a record ID. I think you need to research "database table normalization" - it is very important and I think it relates to your problem.

  3. #3
    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
    Why are sequential numbers important to you? They are not necessarily import to the database management system.
    Autonumbers only provide unique values -- not necessarily incremental and not necessarily positive.
    As Micron said --review Autonumbers.


  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    As already stated, don't use autonumber to generate an identifier that has meaning to users. If you must have a sequential, no gap reference identifier then will need VBA. Generating custom unique identifier is a common topic. Search forum.

    Why delete client record? Deleting records should be a rare event. Once they're gone, they're gone for good (unless you have backup files). Better would be to tag a client as "Inactive" and filter records.
    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. Replies: 6
    Last Post: 07-09-2015, 06:04 AM
  2. Replies: 3
    Last Post: 01-15-2014, 10:39 PM
  3. Get last ID of primary key automatically generated
    By California2013 in forum Access
    Replies: 1
    Last Post: 09-12-2013, 05:57 AM
  4. Replies: 4
    Last Post: 05-07-2012, 12:08 PM
  5. Replies: 2
    Last Post: 07-28-2011, 09:20 PM

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