How to restart counting from 1 after erasing table in MS Access?

前端 未结 6 2090
栀梦
栀梦 2020-11-27 04:39

I have table in MS Access that has an AutoNumber type in field ID

After inserting some rows, the ID has become 200

6条回答
  •  北海茫月
    2020-11-27 04:55

    You can use:

    CurrentDb.Execute "ALTER TABLE yourTable ALTER COLUMN myID COUNTER(1,1)"
    

    I hope you have no relationships that use this table, I hope it is empty, and I hope you understand that all you can (mostly) rely on an autonumber to be is unique. You can get gaps, jumps, very large or even negative numbers, depending on the circumstances. If your autonumber means something, you have a major problem waiting to happen.

提交回复
热议问题