Open Recordset("SELECT TOP 1 * FROM item ORDER BY Item ID DESC", db Open Dynaset, db See Changes) r. Update ''// At this point another user adds a new record r. Move First ''// ORDER BY Item ID DESC means that you're going to see the new user's row Debug. But I leave this response here in case that is your use case and you are just searching for an answer to the general question of how you get the ID of the last inserted record.
As pointed out in the comment below, this process will not work if you are using a different backend than Microsoft Access.
I suppose I could use a Stored Procedure with ADO to get around this problem. Edit1: I'm now using the following code and it is doing what I need/want it to.
Open Recordset("SELECT TOP 2 * FROM item ORDER BY Date Time Modified DESC", db Open Dynaset, db See Changes) r. I know I could use something like DLookup or DMax but I don't think that would be considered bullet proof in a multi-user environment. Open Recordset("SELECT TOP 1 * FROM item ORDER BY Item ID DESC", db Open Dynaset, db See Changes) r. The lastmodifed bookmark is not required for updating of existing reocrds, but is for new records.
Now you can ask questions directly to me on my new site ASPForums.
Net Question Answer site, specially started to allow visitors of this site ask their doubts and queries. Just click the Ask Now button and ask your question now.
Value Key point: instead of using 'SELECT TOP 2' or 'SELECT TOP 1', etc. I verified in sql profiler that opening the recordset does not generate any queries to SQL Server.
When you create files with the various Creative Apps from Adobe, the files are yours.You will need to be online when you install and license your software.If you have an annual membership, you’ll be asked to connect to the web to validate your software licenses every 30 days.You computer does have to connect to the internet once a month to verify that your membership is still current, but that’s it.Once that check has happened you can disconnect and run all of your Creative Cloud apps OFF-line.