About access

I have a table in access with CustomerID as primary key and autonumber. If i delete all rows and add a new the CustomerID value does not begin from 1. I any way to delete all rows and the CustomerID value to begin from 1

Answer this question

About access

  • AlGee

    That happens with all autonumbersing in databases. The database keeps track of the current position of the number and increments it from that position, regardless of what the user does on the table.

    If you want the first record to be record 1, you will have to do that logic yourself without autonumbering.


  • John Cunningham - MSFT

    I copied this from someplace I no longer remember:

    "Settings for AutoNumbers in a table can be customized through SQL Specific Query (In Query Design View, Click Query -> SQL Specific). Sample SQL statements are given below -

    (a) Modifying an existing Table -

    ALTER TABLE T_Books ALTER COLUMN BookID COUNTER (2000, 10)

    The above Query when run, modifies the settings for AutoNumbers In Column [BookID] Of Table [ T_Books] as follows -

    StartValue (Henceforth) = 2000

    Increment Value (Henceforth) = 10

    (If AutoNumber field is also the Primary Key, New start value should be so chosen as not to result in duplication of any existing value)"

    Another solution: Create new autonumber column. Delete original column. Rename new column to old column name.

    hth

    - Pete



  • About access