INSERT INTO statement, new record: how to grab autoid number created?
-
22-09-2019 - |
Question
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?
Could I just turn around and SELECT against the table and use rs.last?
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow