INSERT INTO语句,新的纪录:如何抓住自动识别号产生的?自动识别、语句、纪录、INSERT

2023-09-09 21:21:23 作者:偷了月亮的猫

我有一个按钮点击事件发生的控制信息,并通过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。请参阅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.