Reset MS Access AutoInc Field

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Locked
David de Argentina
Posts: 1596
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina
Contact:

Reset MS Access AutoInc Field

Post by David de Argentina »

Save as "Reset_Autoinc" into the Functions Folder

Code: Select all

{NeoBook Function}
Version=5.80
Language=NeoBook
Param=[%1]|Text|Database ID
Param=[%2]|Text|Table Name
Param=[%3]|Text|AutoInc Field
{End}
dbpExecSQL "[%1]" "SELECT * INTO TempTable FROM [%2];" ""
dbpOpenTable "[%1]" "TempTable" ""
dbpDropField "[%1]" "TempTable" "[%3]"
dbpAddField "[%1]" "TempTable" "[%3]" "AutoInc"
dbpDropTable "[%1]" "[%2]"
dbpExecSQL "[%1]" "SELECT * INTO [%2] FROM TempTable;" ""
dbpDropTable "[%1]" "TempTable"
Usage:

Code: Select all

Call "Reset_AutoInc" "DB" "TableName" "ID"
Enjoy !
David de Argentina
User avatar
dpayer
Posts: 1394
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Reset MS Access AutoInc Field

Post by dpayer »

David de Argentina wrote:Save as "Reset_Autoinc" into the Functions Folder
Enjoy !
David de Argentina

David, just to be clear, is the goal of this function to take an Access DB table, delete/modify the autoincrement column and then renumber from 1 (or from 0) the records in that column?

David P.
David Payer
Des Moines, Iowa
USA
Locked