INSERT INTO语句,新的纪录:如何抓住自动识别号产生的? [英] INSERT INTO statement, new record: how to grab autoid number created?

查看:148
本文介绍了INSERT INTO语句,新的纪录:如何抓住自动识别号产生的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮点击事件发生的控制信息,并通过INSERT进入到一个表进VBA的SQL语句。

I have a button click event that takes information from controls and enters it into a table via INSERT INTO SQL statement in VBA.

我在想,如果有什么我可以添加到这一点,或获取备案创建的记录编号一些其他的方法?

I was wondering if there is anything I could add to this, or some other method to acquire the record number that is created for the record?

难道我就转身选择对阵表和使用rs.last?

Could I just turn around and SELECT against the table and use rs.last?

推荐答案

您可以从您previously执行INSERT语句中相同的DAO.DATABASE对象变量SELECT @@ IDENTITY。请参阅<一href="http://stackoverflow.com/questions/1628267/autonumber-value-of-last-inserted-row-ms-access-vba/1633346#1633346">here在堆栈溢出了解详细信息。

You can "SELECT @@IDENTITY" from the same DAO.Database object variable where you previously executed your INSERT statement. See here on Stack OverFlow for details.

这篇关于INSERT INTO语句,新的纪录:如何抓住自动识别号产生的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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