Followup on what Pat Hartman mentions.
If you were to execute the query on an ADO connection, you could fetch the last identity (autonumber) using the same connection, something along the following lines:
' dynamic SQL
myconn.execute "<TheSql>", , adCmdText + adExecuteNoRecords
' query/SP
myconn.execute "QueryName", , adCmdStoredProc + adExecuteNoRecords
' for Jet
Set rs = myconn.Execute("SELECT @@Identity", , adCmdText)
' for SQL Server
Set rs = myconn.Execute("SELECT ScopeIdentity()", , adCmdText)
Debug.print "Last identity " & rs.fields(0).value
Or, for SQL server, you might "do it all in one" - have the SP return the result of the SELECT ScopeIdentity(), and execute like this
set rs = myconn.execute("SPName", , adCmdStoredProc)
Identity is safe to use in Jet settings. For SQL server, you'd need to ensure you get the last identity in this scope - i e the identity of this process, not whatever new record caused by a trigger executed based on your operation (or by triggers created by SQL server).