0

So, I know how to add an autonumber field to a table using SQL:

dblocal.Data.Execute "CREATE TABLE " & TableName & " (" & FieldName & " COUNTER(1,1) )"

Where dblocal is the passed database reference with TableName & FieldName the appropriate names for the desired creation of the table.

However, I want the counter to start at ZERO not ONE. And I know it's possible because the table I need to repair / duplicate starts with ZERO

What am I not finding on the internet to aid me in this task? My search-fu fails me.

braX
  • 11,506
  • 5
  • 20
  • 33
Colin
  • 47
  • 4
  • 3
    Why the `Excel` and `VBA` tags? – BigBen Jun 03 '20 at 20:39
  • 3
    Why bother? (You shouldn't build applications depending on a specific value.) – jarlh Jun 03 '20 at 20:42
  • 1
    If it were possible (not sure, haven't tried it) then I would assume that `COUNTER(1,1)` should be `COUNTER(0,1)` – JNevill Jun 03 '20 at 20:49
  • 1
    Tested and works. Also wonder why needed. – June7 Jun 03 '20 at 20:52
  • The primary key / ID of a record should have no meaning whatsoever - as such its value is utterly irrelevant, or *should* be. Consider separating concerns and making whatever value you have that has a semantic meaning in your application, NOT be the table's primary key (assuming there *is* a primary key - that's typically what autonumber columns are used for) – Mathieu Guindon Jun 03 '20 at 21:53
  • 1
    Also it [seems](https://stackoverflow.com/questions/7691253/equivalent-of-set-identity-insert-off-in-access) Access lets you insert IDs without a fuss, so if the reason is migration of existing data... the identity seed isn't really relevant then. – Mathieu Guindon Jun 03 '20 at 21:57

0 Answers0