自动递增数字字段(不是自动编号字段) [英] Auto Incrementing a number field (not autonumber field)

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

问题描述

我有一个包含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


这篇关于自动递增数字字段(不是自动编号字段)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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