自动递增数字字段(不是自动编号字段)

编程入门 行业动态 更新时间:2024-10-24 04:48:50
本文介绍了自动递增数字字段(不是自动编号字段)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个包含4个表的数据库:tblMembers,tblRides,Session table和Reservation table。 Members表中的一个字段设置为number,但是现在我已经设置了所有关系并插入了数据,但现在有一个问题是当我添加一个新用户时它没有增加..有什么办法吗?使用VBA,我可以从表中获取最后一个CustomerID并添加一个,并将其作为新ID插入? 我想抓住最后一个使用的CustomerID

展开 | 选择 | Wrap | 行号

解决方案

这不会返回值。 DoCmd.RunSQL不返回任何值。另外,您当前的代码会抛出错误,因为您的SQL字符串不是动作查询。 使用DMax函数返回最大数字,然后为新数字添加1 。

其中 CustID 是保存增加数字的文本框,类似于:

展开 | 选择 | Wrap | 行号

其中 CustID 是保存增加数字的文本框,类似于:

展开 | 选择 | Wrap | 行号

I have a database with 4 tables: tblMembers, tblRides, Session table and Reservation table. One of the fields in the Members table is set to number, but now I have all relationships set up and the data inserted, but one problem is now that when I add a new user it doesn''t increment.. Is there any way with VBA, that I can grab the last CustomerID from the table and add one to it, and insert that as the new ID? I was thinking to grab the last CustomerID of using

Expand|Select|Wrap|Line Numbers

解决方案

That would not return a value. DoCmd.RunSQL does not return any values. Plus, your current code will throw an error because your SQL string is not an action query. Use the DMax function to return the highest number and then add 1 to it for the new number.

Where CustID is the textbox holding the incremented number, something like:

Expand|Select|Wrap|Line Numbers

Where CustID is the textbox holding the incremented number, something like:

Expand|Select|Wrap|Line Numbers

更多推荐

自动递增数字字段(不是自动编号字段)

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

发布评论

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

>www.elefans.com

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