自动生成数字 [英] Generating Numbers automatically

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

问题描述

我正在使用Access 2002.

我有一个名为Job No.的字段

这是一个文本(数据类型)。原因是存在I。每个号码前面是

,即I1234 I1235等

问题是当用户输入新记录时,他/她必须知道

最后记录的工作没有。存在于数据库中,以便然后

分配下一个顺序作业no。所以这是一个手动过程。

我不想分开我。来自作业编号字段的组件按顺序

使字段成为自动编号数据类型。

是否有一些代码可用于允许系统以某种方式自动

分配包含前缀I的下一个序号。每个

号码?

感谢您的帮助。

I''m using Access 2002.
I have a field called Job No.
It is a text (data type). The reason being that there is an "I" in front of
each number i.e. I1234 I1235 etc
The problem is that when the user enters a new record, he/she has to know
what the last recorded job no. is present in the database, in order to then
assign the next sequential job no. So its a manual process.
I don''t want to seperate the "I" component from the Job No. field in order
the make the field an autonumber datatype.
Is there some code I could use to allow the system to somehow automatically
assign the next sequential number incorporating the prefix "I" to each
number ?
thank you for any help.

推荐答案

Gary写道:
我正在使用Access 2002.
我有一个名为Job No.的字段
它是一个文本(数据类型)。原因是存在I。在每个号码的前面,即I1234 I1235等
问题是,当用户输入新记录时,他/她必须知道最后记录的作业没有。存在于数据库中,然后按顺序分配下一个顺序作业no。所以它是一个手动的过程。
我不想分开我这个过程。
中的作业编号字段中的组件使字段成为自动编号数据类型。
是否有一些代码可用于允许系统以某种方式自动分配包含以下内容的下一个序列号
前缀我每个号码?
感谢您的帮助。
I''m using Access 2002.
I have a field called Job No.
It is a text (data type). The reason being that there is an "I" in
front of each number i.e. I1234 I1235 etc
The problem is that when the user enters a new record, he/she has to
know what the last recorded job no. is present in the database, in
order to then assign the next sequential job no. So its a manual
process.
I don''t want to seperate the "I" component from the Job No. field in
order the make the field an autonumber datatype.
Is there some code I could use to allow the system to somehow
automatically assign the next sequential number incorporating the
prefix "I" to each number ?
thank you for any help.




DMax(Mid(FieldName,2),TableName)


应该检索最高值,但由于它必须首先使用Mid()

函数,所以它将是低效的。你真的应该把b $ b变成我。实际上,如果它总是I,则它是分开的。它根本不需要将b $ b存储在表格中。您可以只存储数字和

使用格式设置*显示*它与我相同。在前面使用

实际数字字段,在这种情况下,DMax(FieldName,TableName)将更有效率。

。特别是如果你向

字段添加一个降序索引。


-

我没有查看电子邮件帐户附上

到此消息。发送给... ...

在Hunter dot com的RBrandt



DMax("Mid(FieldName,2)", "TableName")

Should retrieve the highest value, but since it is having to use the Mid()
function first it is going to be inefficient as hell. You REALLY should
make the "I" separate and in fact if it is always an "I" it doesn''t even
need to be stored in the table at all. You could store just the number and
use a format setting to *display* it with an "I" in the front while using an
actual number field in which case DMax("FieldName", "TableName") will be
much more efficient. Particularly if you add a descending index to the
field.

--
I don''t check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Gary写道:
我正在使用Access 2002.
我有一个名为Job No.的字段
这是一个文本(数据类型)。原因是存在I。在每个号码的前面,即I1234 I1235等
问题是,当用户输入新记录时,他/她必须知道最后记录的作业没有。存在于数据库中,然后按顺序分配下一个顺序作业no。所以它是一个手动的过程。
我不想分开我这个过程。
中的作业编号字段中的组件使字段成为自动编号数据类型。
是否有一些代码可用于允许系统以某种方式自动分配包含以下内容的下一个序列号
前缀我每个号码?
感谢您的帮助。
I''m using Access 2002.
I have a field called Job No.
It is a text (data type). The reason being that there is an "I" in
front of each number i.e. I1234 I1235 etc
The problem is that when the user enters a new record, he/she has to
know what the last recorded job no. is present in the database, in
order to then assign the next sequential job no. So its a manual
process.
I don''t want to seperate the "I" component from the Job No. field in
order the make the field an autonumber datatype.
Is there some code I could use to allow the system to somehow
automatically assign the next sequential number incorporating the
prefix "I" to each number ?
thank you for any help.




DMax(Mid(FieldName,2),TableName)


应该检索最高值,但由于它必须首先使用Mid()

函数,所以它将是低效的。你真的应该把b $ b变成我。实际上,如果它总是I,则它是分开的。它根本不需要将b $ b存储在表格中。您可以只存储数字和

使用格式设置*显示*它与我相同。在前面使用

实际数字字段,在这种情况下,DMax(FieldName,TableName)将更有效率。

。特别是如果你向

字段添加一个降序索引。


-

我没有查看电子邮件帐户附上

到此消息。发送给... ...

在Hunter dot com的RBrandt



DMax("Mid(FieldName,2)", "TableName")

Should retrieve the highest value, but since it is having to use the Mid()
function first it is going to be inefficient as hell. You REALLY should
make the "I" separate and in fact if it is always an "I" it doesn''t even
need to be stored in the table at all. You could store just the number and
use a format setting to *display* it with an "I" in the front while using an
actual number field in which case DMax("FieldName", "TableName") will be
much more efficient. Particularly if you add a descending index to the
field.

--
I don''t check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


好点。加里

good point. gary


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

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