Access AutoNumber Feature

K

Keith Davis

Is there a way to get the AutoNumber feature in Access to
begin incrementing at a number other than 1? For example,
to begin the numbers assigned to a customer ID field at
4001 instead of 1. The AutoNumber field would then
generate 4001,4002,4003,4004, etc for each successive
field.

Thanks in advance!
 
A

Allen Browne

Simplest approach is to programmatically add a record 1 less than you want,
and then delete it. Provided you do not compact before records are added,
they will begin where you want.

Details:
Set AutoNumbers to start from ...
at:
http://allenbrowne.com/ser-26.html

In Access 2000 and later, it is possible to achieve the same result by
setting the Seed property of the automumber column using ADOX code.
 
P

Pavel Romashkin

Although Allen is indeed correct, there is a simpler way. All you need
to do is run an INSERT query on a new, blank table with AN that will put
4000 into the AN field:

INSERT INTO MyTable (myAutoNumber) VALUES (4000)

Pavel
 
K

Keith Davis

Thanks for the help Pavel. Could you point me in the
direction of where I could find information in performing
an Insert Query? Is this the same as an Append or Update
query?
 
P

Pavel Romashkin

Insert is actually what the Access query designer calls Append. All you
have to do is click on Create new query, cancel the table selection
dialog that comes up, then right-click and choose "SQL view". Type the
statement you need and press the [!] on the tool bar to run the query.
Make sure that you replace [myAutoNumber] in my suggestion with the name
of your field (I guess it would be CustomerID or something like that).

Pavel
 

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