下面是我的数据样本:
ID
- 自动编号
〜是他们的主键
周
- 从字面上本周仔猪出生
母猪订单
- 母猪数量
ID
- autonumber
~ is their primary key
Week
- literally the week piglets were born
Sow Order
- Sow number
规则: 1.如果仔猪同一周出生的,不管他们的母猪。仔猪编号继续 2.如果仔猪在下周出生,编号返回到0001,然后第1。
Rules: 1. If piglets were born the same week, regardless their Sow. Piglet numbering continues 2. If piglets were born next week, numbering returns to 0001 then Rule 1.
的方式小猪无以复加的,每周+播种+(小猪数)
。例如,(10),它会产生10小猪0001到0010在周= 01安培;母猪= 01。
The way piglets were to be added is, week + sow + (number of piglets)
. For example, (10), it will generate ten piglets 0001 to 0010 in week=01 & sow=01.
现在的问题是,如果用户对仔猪的数量是错误的加入?根据图片, 01 01有两个仔猪
,如果它不只是2?说,其3。因此用户需要删除它,然后编号必须进行调整,以..
The problem is, what if the user had a mistake on the number of piglets to be added? Based on the picture, 01 01 has two piglets
, what if its not just 2? Say, its 3. So user need to delete it and then numbering MUST be adjusted to..
01 | 01 | 0001
01 | 01 | 0002
01 | 01 | 0003
01 | 02 | 0004
01 | 02 | 0005
什么是正确的方法做这种东西?
What is the proper method to do this kind of stuff?
如果Access数据库版本至少Access 2010中则事件驱动的数据宏可以用来执行的编号方案。对于命名表[小猪]
If the Access database version is at least Access 2010 then event-driven data macros can be used to enforce the numbering scheme. For a table named [Piglets]
数据宏[AfterInsert]:
with data macros for [AfterInsert]:
[更新后]:
[AfterDelete]:
[AfterDelete]:
和一个名为数据宏[RenumberPiglets]:
and a named data macro [RenumberPiglets]:
重新编号自动发生,即使该表从外部应用程序更新(例如,VB.NET或C#)。
the renumbering takes place automatically, even if the table is updated from an external application (e.g., VB.NET or C#).
对于Access数据库版本2007和早期,类似的逻辑就必须写入数据输入表单(S)用于更新表。
For Access database versions 2007 and earlier, similar logic would have to be written into the data-entry form(s) used to update the table.