2012-07-16 65 views
0

我有一个访问表单,将数据保存在数据库中,我希望其中一个字段自动计算为行中的下一个值作为ID,以便用户不写入ID。有没有人有任何想法?访问中的表单自动编号

+0

看到这篇文章:http://superuser.com/questions/288087/how-do-i -set最第一值的-自动编号-在存取 – 2012-07-16 14:28:55

回答

2

使用自动编号数据类型创建您的表格。

0

如果您手动创建表,然后这个说法

CREATE TABLE TableThatIncrements 
(
    Id AUTOINCREMENT(1001,1) 
) 

或者您可以使用编辑现有的表ID列:

ALTER TABLE TableThatIncrements 
    ALTER COLUMN Id AUTOINCREMENT(1001,1) 

如果你没有,那么你可以按照文章改变我通过GUI界面提到。请参阅本文中的步骤:https://superuser.com/questions/288087/how-do-i-set-the-first-value-of-autonumber-in-access

您可以在Access中运行查询通过执行以下操作:

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".