Although Access doesn't offer this function natively, it can be achieved through a query, like the following:
CREATE TABLE TableThatIncrements
(
Id AUTOINCREMENT(1001,1)
)
This will create a single table that's called "TableThatIncrements" with a single column, named "Id". You can now use the table editor to add properties and/or other columns.
Change
AUTOINCREMENT(x,y)
to suit your needs, where
x
is the initial increment number and y
is the number to increment with. SoAUTOINCREMENT(100,5)
will yield: 100, 105, 110, 115, etc.
If you want to alter an existing table, use the following query. Make sure that specific table's tab is closed so Access can lock it down and alter it.
ALTER TABLE TableThatIncrements
ALTER COLUMN Id AUTOINCREMENT(1001,1)
You can run a query in Access by doing the following:
- Go to the "Create" tab and click "Query Design"
- Just close the window that appears which asks you to select tables, we don't need that.
- Go to the "Design" tab and click the button with the arrow until you get a textual input screen. (By default, it says
SELECT;
).
- Delete the default text and paste the above query.
- Click "Run".
No comments:
Post a Comment