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

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
 
K

KARL DEWEY

Append a record that has 34889 in the Autonumber field. Then delete the
record. Do not compact until you have added more records.
 
A

Albert D.Kallal

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top