access2003, is there a way to autonumber at a specific number

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

access2003, is there a way to start autonumber at a specific number sequence.
I want to start off with a number like 34890. Is this possible in microsoft
access2003
 
Append a record that has 34889 in the Autonumber field. Then delete the
record. Do not compact until you have added more records.
 
You can use the follwign code.

Sub SetNextID()

Dim strTable As String
Dim strSql1 As String
Dim strSql2 As String
Dim ibuf As String
Dim nextvalue As Long


strTable = InputBox("What table to modify")
If strTable = "" Then Exit Sub

strSql1 = "INSERT INTO " & strTable & " (ID) SELECT TOP 1 "
strSql2 = "DELETE ID FROM " & strTable & " WHERE ID = "

ibuf = InputBox("Enter next value (blank enter will exit)")
If ibuf <> "" Then
nextvalue = ibuf - 1
CurrentDb.Execute strSql1 & nextvalue & " AS Expr1 from " & strTable
' now delete this guy
CurrentDb.Execute strSql2 & nextvalue
End If

End Sub

However, you really should not need to do the above.
 
Back
Top