有什么办法可以在表格中定义自动增量字段的起始值 [英] Is there any way I can define a starting value for an Auto-Increment Field in a table

查看:60
本文介绍了有什么办法可以在表格中定义自动增量字段的起始值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一张桌子,其主键是自动增量字段:

Equipment_Number。

在M.S.访问是否有任何方法可以定义该字段的起始编号?


或另一种可以保存相同问题的方法是:


我有一个表格frmAddNew_Equipment,一旦所有字段都填写正确并且已经确认没有双重输入等,并且点击了保存按钮(未绑定表单),另一个表单绑定到查询弹出新设备编号。然后,使用数据库的人抓取物理标签并将其附加到新设备上。但是标签从1000开始。无论如何,我可以修改我在弹出窗体中使用的查询,这样1000将被添加到查询生成的数字,然后新的数字显示在弹出的文本框中表单。


这是在弹出窗体中驱动New Equipment_Number文本框字段的查询:

Hi

I have a table that has as its Primary Key the Auto-Increment Field:
Equipment_Number.
In M.S. Access is there any way to define a starting number for the field?

OR another way in which I could save the same problem would be:

I have a form frmAddNew_Equipment, once all the fields are filled in correctly and it has been verified that there is no double entry etc, and the ''SAVE'' button is clicked (unbound form), another form, bound to a query pops up with the new equipment number. The person using the database then grabs a physical Label and attaches that to the new piece of equipment. However the labels start at number 1000. Is there anyway I can modify the query I use in the pop up form, so that 1000 will be added to the number the query produces, before the new number is displayed in a text box on the pop up form.

This is the query that drives the New Equipment_Number textbox field on the pop up form:

展开 | 选择 | Wrap | 行号

推荐答案





我有一张表作为其主键自动增量字段:

Equipment_Number。

在M.S.访问是否有任何方法可以定义该字段的起始编号?


或另一种可以保存相同问题的方法是:


我有一个表格frmAddNew_Equipment,一旦所有字段都填写正确并且已经确认没有双重输入等,并且点击了保存按钮(未绑定表单),另一个表单绑定到查询弹出新设备编号。然后,使用数据库的人抓取物理标签并将其附加到新设备上。但是标签从1000开始。无论如何,我可以修改我在弹出窗体中使用的查询,这样1000将被添加到查询生成的数字,然后新的数字显示在弹出的文本框中表单。


这是在弹出窗体中驱动New Equipment_Number文本框字段的查询:


SELECT tblEquipment.Equipment_Number

FROM tblEquipment

WHERE(((tblEquipment.Serial_ID)=(Forms!frmAdd_Equipment!txtSerial_Number)));


再次谢谢你任何帮助


Mike
Hi

I have a table that has as its Primary Key the Auto-Increment Field:
Equipment_Number.
In M.S. Access is there any way to define a starting number for the field?

OR another way in which I could save the same problem would be:

I have a form frmAddNew_Equipment, once all the fields are filled in correctly and it has been verified that there is no double entry etc, and the ''SAVE'' button is clicked (unbound form), another form, bound to a query pops up with the new equipment number. The person using the database then grabs a physical Label and attaches that to the new piece of equipment. However the labels start at number 1000. Is there anyway I can modify the query I use in the pop up form, so that 1000 will be added to the number the query produces, before the new number is displayed in a text box on the pop up form.

This is the query that drives the New Equipment_Number textbox field on the pop up form:

SELECT tblEquipment.Equipment_Number
FROM tblEquipment
WHERE (((tblEquipment.Serial_ID)=(Forms!frmAdd_Equipment !txtSerial_Number)));

Again thank you for any help

Mike



嘿Mike,


这是一个MS Access数据库的所有新用户都属于这些原因。您无法在不操作数据库的情况下将自动编号字段的ID编号更改为固定编号。如果您的数据库的计数为10并且您想要转到999,那么您将向数据库中添加适当数量的记录(989),因此下一个发布的数字将为1000.没有任何功能如果由于某种原因导致数字不按顺序排列,则根本调整此数字。这就是为什么将Autonumber Primary Key字段用作产品代码并不总是一个好主意,因为它不可更改。


只要你对我好解决方案,应该允许您更改数字,但除此之外,没有任何其他方法可以更改MS Access数据库中的自动编号字段的数量。


现在要更改它,您必须清除条目表,在数据库上执行压缩,然后将数字重置为1.这是您操作自动编号字段的唯一选项。



希望有所帮助,


Joe P。


Hey Mike,

This is one of those reasons that all new users of MS Access database fall into. You''re not able to change the ID number of Autonumber field to a fixed number without manipulating the database a little. If you''re database has a count of 10 and you want to go to 999, then you would add the appropriate number of records to the database (989), so the next number that is issued would be 1000. There is no feature to adjust this number at all if, for some reason that the numbers get out of sequence. this is why this is not always a good idea to use the Autonumber Primary Key field as a product code, because it is not changable.

As long as you''re ok with my solution, that should allow you to change the number, but other than that, there isn''t any other way to change the number a Autonumber field in a MS Access Database.

Now to change it back, you would have to clear the entry table, perform a compact on the database, and that will reset the number back to 1. Those are your only options for manipulating the autonumber field.


Hope that helps,

Joe P.


作为正式会员,您应该知道我们期待您的代码将发布在[代码]标记中(请参阅如何提出问题)。

这使我们的专家更容易阅读和理解它。如果不这样做会给版主带来额外的工作,从而浪费资源,否则可以回答会员的问题。

请将来使用这些标签。


管理员。
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members'' questions.
Please use the tags in future.

Administrator.


你的问题的简短答案(我试着简单,但它并不是我自然而然)是自动编号类型,虽然看起来好像它可能是在这种情况下的合适选择,不是。


标准方法是找到一种确定新索引值应该是什么的替代方法。这样,您可以使用几乎无限的灵活性来使用值。
The short answer to your question (I try to be uncomplicated but it doesn''t come naturally to me) is that the AutoNumber type, though it looks as if it may be the appropriate choice in such a situation, is not.

The standard approach is to find an alternative method of determining what a new index value should be. That way you have an almost unlimited flexibility to which values are used.


这篇关于有什么办法可以在表格中定义自动增量字段的起始值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆