客户自动编号增量?

编程入门 行业动态 更新时间:2024-10-11 03:15:13
本文介绍了客户自动编号增量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道这个问题就像一个破纪录,但我找不到一个简单的答案,我是Access / VBA的新手,但我可以找到自己的方式所以我对下面的说明没有问题,所以我希望有人有时间帮我解决这个问题。 这里有一个包含多个字段的表格如下 工作号码< ----自动编号和主键 客户 工作完成 我需要确保每个作业号都是递增的,也是一个无法复制的唯一键。现在,当我使用Access Autonumber时,如果我意外地将新记录添加到表单并按下escape,它会变得很愚蠢。所以当我决定添加另一条记录时,序列就消失了。 我知道这不能在表级别上完成,所以它需要在表单级别完成,有没有办法创建一个方法来增加基于最后一个的数字记录? 我很感激帮助,我很绝望:( 谢谢 Sam

Hi, I know this question is like a broken record but I cannot find a simple answer to follow, I am new to Access/VBA but I can find my way round so I do not have a problem with following instructions so I hope someone will have the time to help me out on this one. Here goes, I have a table with a number of fields as follows Job Number <---- Auto Number and Primary Key Customer Work Done I need to make sure that each job number is increment and also a unique key which cannot be duplicated. Now when I use the Access Autonumber it goes stupid if I accidently add a new record to a form and press escape. so when I decide to add another record the sequence is gone. I know this cannot be done on a table level, So it needs to be done on a form level, is there a way to create a method to increment the numbers based on the last record? I would appreciate the help and I am desperate :( Thank you Sam

推荐答案

DMAX 是解决方案。简单,直接。 更改自动编号字段到Normal Number字段。并为该字段设置默认值 DMAX is the solution. Easy, Simple and straight forward. Change the Autonumber field to Normal Number field. and make the default value for that field 展开 | 选择 | Wrap | 行号s

这个问题很清楚。你是对的,因为它经常被问到。尽管如此,它很少被清楚地问清楚。这是一个令人愉快的例外。 就其而言,阿里的答案是好的。它已得到很好的解释并涵盖了基本概念。 但是,在某些情况下,可能需要的是在多用户环境中处理此问题。在这样的环境中,或者在开发可能在将来以这种方式使用的工作时,重要的是只需检查表并在写出记录时准备一个值(在 Form_BeforeInsert()中事件程序)。 这意味着事先无法向操作员显示该值。许多人发现这种奇怪且非用户友好,但这只是因为他们没有正确掌握这些概念。在创建记录之前,您永远不会看到自动编号的值。那是因为在创建记录之前它不存在。如果你坚持这个设计,你就不会出错。 最后,如果在创建新记录后删除记录,则无法保证序列号。这只能保证数字以正确的顺序创建。 This question is unusually asked clearly. You''re right in that it''s asked quite frequently. It''s rarely asked clearly though. This is a pleasant exception. As far as it goes Ali''s answer is good. It''s well explained and covers the basic concepts. What may be additionally required though, but only in some circumstances, is the handling of this in multi-user environments. In such an environment, or for when developing work which may be used that way in future, it is important only to check the table and prepare a value at the point of writing away the record (In the Form_BeforeInsert() event procedure). This does mean that the value cannot be shown to the operator beforehand. Many find this strange and un-user friendly, but that''s only because they don''t properly grasp the concepts. You''ll never see the value of an AutoNumber showing until the record is created. That''s because until the record is created it doesn''t exist. If you keep to this design you won''t go far wrong. Lastly, the sequence numbers cannot be guaranteed if records are removed after new ones have been created. This only guarantees that the numbers are created in the correct sequence.

DefaultValue方法的一个问题是defaultValues是已加载的。当记录开始编辑时。这意味着如果用户A开始记录10(9是最后保存的记录)并且用户B在用户A保存之前开始记录,则两个记录将是10(并且保存将失败,并且具有关于在索引中创建重复值的消息。 ) 我建议在Forms Before update事件中执行此操作。如果您选择FORM的属性(单击表单的左上方框)并选择Events,请转到BeforeUpdate。单击右侧的3 ...,然后选择Event Procedure,将显示Visual Basic for Applications(VBA)编辑器窗口。访问将为您准备好一些信息,如下所示: One problem with the DefaultValue approach is that defaultValues are "loaded" when the record starts being edited. This means that if user A starts record 10 (9 was the last saved record) and user B starts a record before user A saves, both records will be 10 (and the save will fail, with a message about creating duplicate values in index.) I would recommend doing it in the Forms Before update event. If you select your FORM''s properties (click top left box of your form) and select Events, go for BeforeUpdate. Click the 3 ... on the right hand side, and select Event Procedure and you will be shown a Visual Basic for Applications (VBA) editor window. Access will have filled in some information for you allready, looking like this: 展开 | 选择 | Wrap | 行号

更多推荐

客户自动编号增量?

本文发布于:2023-10-30 18:23:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1543646.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:增量   编号   客户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!