Re-Seed an Access Auto Number field
Public Sub ResetAutoNumberSeed(strTablename As String, _
        strColumnName As String , _
        Optional lngNewStartValue As Long = 1, _
        Optional lngNewIncrement As Long = 1 )
' Purpose   Allow the user the re-seed an Access Auto Number field
' Author    Ron Weiner
'           Copyrite 2001-2005 WorksRite Software Solutions
'           You may use this code example for any purpose what-so-ever with
'           acknowledgement. However, you may not publish the code without
'           the express, written permission of the author.
    Dim cat As New ADOX.Catalog
    Dim col As New ADOX.Column

    cat.ActiveConnection = CurrentProject.Connection
    Set col = cat.Tables(strTablename).Columns(strColumnName)
    col.Properties("Seed") = Clng(lngNewStartValue)
    col.Properties("Increment") = Clng(lngNewIncrement)
    Set cat = Nothing
    Set col = Nothing
End Sub


Copyright 2001 WorksRite Software Solutions -- Last Updated 06/13/05
Problems with this site? Please contact the with your comments, questions, or suggestions.