Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RESET AUTONUMBER

Status
Not open for further replies.

Johnny42

Technical User
Jul 13, 2004
127
CA
COULD THIS BE USED BY vba TO RESET AUTONUMBER ?

USE MyDatabase
GO
DBCC CHECKIDENT (MyTable, RESEED, 1)
GO
 
I don't think so - have you tried?

One way that would normally work, is

currentdb.execute "ALTER TABLE TableName ALTER COLUMN AutoNumberFieldName COUNTER(N,1)"

Replace TableName and AutoNumberFieldName with the names you use, and N here, is representing starting number, you'll probably need 1?

I don't think it'll work if your autonumber field is used in relationships with other tables, you'd probably need to remove those first.

And please, get a new keyboard where the Caps Lock key isn't stuck;-)

Roy-Vidar
 
Sorry for the caps....Will this work on an MSDE?
 
Don't think so, I think perhaps your code is closer, perhaps single quotes around the table name?

[tt]DBCC CHECKIDENT ('MyTable', RESEED, 1)[/tt]

Autonumbers are an Access thinige;-)

Roy-Vidar
 
Thanks..
DBCC CHECKIDENT ('MyTable', RESEED, 1)
works fine :)
 
Code:
Public Function TabReseed(cnn As Connection, tName As String, fName As String, iSeed As Integer, iInterval As Integer) As Boolean
    Dim str As String
    str = "ALTER TABLE [" & tName & "]" & _
          " ALTER COLUMN [" & fName & "]" & _
          " COUNTER(" & iSeed & "," & iInterval & ")"
    cnn.Execute str
End Function

Want the best answers? See FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top