生成ID号 [英] Generate an ID No.

查看:105
本文介绍了生成ID号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这段代码很方便,但我有一个需要帮助的更高级的问题。我有一个需要一些特殊的唯一编号的数据库。取决于州字段(组合框)上的
...例如:XFO-IA,我需要将

添加到另一个字段中的唯一6位数字。基本上,如果我从States字段中选择XFO-IA,我想调用XFO-IA的下一个唯一编号。每个州

都需要一个唯一的递增数字,因此XFO-TX也可以有000001和XFO-IA。结果将显示XFO-IA000001。下一条记录可能是我从状态字段中选择的XFO-TX,它可以是XFO-TX000001,但它需要是TX的下一个递增数字,因为XFO-TX的最后一条记录可能有XFO-TX001987。如果你可以给我一些方向,我真的很感激!!! !!! div class =h2_lin>解决方案

请为你的问题创建自己的帖子,因为有太多问题可能会让你感到困惑来自同一线程中的不同人。


在您的情况下,您将使用DMax(字段名称,表名称,SQL WHERE子句)来获取该状态的最高编号,并将其增加1.这是简化的,但希望您可以从那里工作。如果您有任何问题,请告诉我们。


Ooops,抱歉。从来没有这样做过。因此,我的字段被命名为具有字段第一部分下拉的状态,例如:XFO-TX。在On Current的Form属性(产生6位数字)下,我有以下VBA代码:


Private Sub Form_Current()

If IsNull( UniqueID)然后

UniqueID =表格![frm_Forestry]![frmIncrement] .Form![增量]

表格![frm_Forestry]![frmIncrement] .Form![Increment ] =表格![frm_Forestry]![frmIncrement] .Form![增量] + 1

结束如果

结束子


你能详细解释我需要放置Dmax线的地方吗?我是否创建了一个文本框?它如何知道我需要哪个州的号码?


This code is handy, but I have a more advanced problem that I need help with. I have a database that needs some special unique numbering. Depending
on the States field (combo box)...ex: XFO-IA, I need to add
a unique 6 digit number in to a different field. Basically, if I select XFO-IA from the States field, I want to call the next unique number for XFO-IA. Each state
needs a unique incrementing number, so XFO-TX can have 000001 and XFO-IA can too. The result will show XFO-IA000001. The next record maybe XFO-TX that I select from the States field, and it can be XFO-TX000001, but it needs to be the next incremented number for TX, because the last record for XFO-TX may have had XFO-TX001987. If you could give me some direction, I would REALLY appreciate it!!!

解决方案

Please create your own posts for your questions as it can get confusing having too many questions coming from different people in the same thread.


In your case you would use the DMax("Field Name", "Table Name", "SQL WHERE Clause") to get the highest number for that state and increment it by 1. This is simplified but hopefully you can work from there. Let us know if you have any problems.


Ooops, sorry. Never done this before. So, my field is named States that has the drop down of the first part of the field, ex: XFO-TX. Under the Form properties for On Current, which produces the 6 digits, I have VBA code of the following:

Private Sub Form_Current()
If IsNull(UniqueID) Then
UniqueID = Forms![frm_Forestry]![frmIncrement].Form![Increment]
Forms![frm_Forestry]![frmIncrement].Form![Increment] = Forms![frm_Forestry]![frmIncrement].Form![Increment] + 1
End If
End Sub

Can you explain in a little more detail where I need to put the Dmax line? Do I create a text box? How does it know which State I need a number for?


这篇关于生成ID号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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