Page 1 of 1

Reset MS Access AutoInc Field

PostPosted: Tue Nov 19, 2013 2:55 pm
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

Re: Reset MS Access AutoInc Field

PostPosted: Wed Nov 20, 2013 8:14 am
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.