MS Access 2003 - 自动分配标识号

发布于 2024-08-17 11:26:20 字数 618 浏览 5 评论 0原文

所以我有一个小数据库,用于新员工的招聘信息,包括他们的职位、地点和内容。发布的一件事是笔记本电脑上的条形码/ID 号很少,我希望数据库在用户保存到数据库时自动分配可用的 ID 号。

所以我有一个用户用来输入信息的表单,并且它是未绑定的,因此信息通过单击按钮时的 INSERT 保存。 ID号有所不同,因为它在特定范围内......所以可以说它的ID#001 - ID#100,并且由于人们离开并归还他们的装备而在该范围内有gps,我想要它自动使用该范围内的最低可用数字。

这有道理吗?我怎样才能完成这件事?

谢谢

,我想我还应该提到,我并不是真的在寻找它作为表的“ID”(除非有必要)....我只是使用 ID# 作为示例....它可能是 EQUIP# 001-EQUIP#500 我关心的一切。

  • 编辑:

所以我所说的 ID# 是反映我打算使用它的目的的术语,而不是访问自动编号 ID。我需要创建一个装备 ID 字段,该字段使用诸如 LT#1000-LT#2000 之类的范围。在此范围内,我想在创建时自动为创建的每个新记录分配可用的最低数字(我只想使用最低数字,以防我有 220 个用户,但 #112 将他的装备交还回来,然后下一个乔来一起得到分配112。

所以我希望我能理解这一点。

So I have a little db that is used for new hires in terms of who, where and what they are issued. One thing that is issued is laptops with little barcode/ID numbers, and I would like the db to auto assign an available ID number when the user is saved to the db.

So I have a form that users use to input the information, and it is unbound, so the info saves via INSERT on button click. The ID number varies, because it is within a specific range.....so lets say its ID#001 - ID#100, and there are gps in that range due to people leaving and handing back in their equip, I want it to use the lowest available number in that range automatically.

does this make sense? how can i get this done?

thanks

I guess i should also mention that I am not really looking for this to be the "ID" of the table (unless its necessary)....i just used ID# as an example....it could be EQUIP#001-EQUIP#500 for all i care.

  • EDIT:

So what I meant by ID# is terminology reflecting what I intend to use this for, not access autonumber ID. I need to create an equipID field that uses a range of something like LT#1000-LT#2000. Within this range I want to auto assign lowest number available to each new record create when its created (i just want to use the lowest number incase i have 220 users, but #112 hands his equip back in, and then the next joe to come along to get assign 112.

So I hope i making sense with this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流心雨 2024-08-24 11:26:20

我认为有几点可能会有所帮助。如果您保留一个单独的资产表,其中包含笔记本电脑,并且标志或状态字段从“In Stock”更改为“Out On Hire”,那么您可以编写一个查询,如下所示:

SELECT MIN([Asset_tag_number]) FROM tblAssets WHERE Status=”In Stock” AND Type=”Laptop”

在保存之前加载该查询的结果记录,它会给你第一个有库存的号码和一台笔记本电脑

There are a few points I can think of that might help. If you keep a separate asset table with the laptops in and have a flag or status field that changed from “In Stock” to “Out On Hire” then you could do write a query to like this

SELECT MIN([Asset_tag_number]) FROM tblAssets WHERE Status=”In Stock” AND Type=”Laptop”

Load the result of that query before you save the record and it will give you the first number it comes up with that is in stock and a laptop

稳稳的幸福 2024-08-24 11:26:20

按照此文章

Use an Autonumber field, as per this article.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文