Seems a common enough problem this, but most solutions refer to concatenating multiple SQL commands, something which I believe can\'t be done with ADO/VBA (I\'ll be glad to
Re: "I have tried to get @@IDENTITY working, but this always returns 0 using the code below."
Your code sends SQL
and SQL2
through different connection objects. I don't think @@identity
will return anything other than zero unless you ask from the same connection where you executed your INSERT
statement.
Try changing this:
myRecordset.Open SQL2, dbConnectionString, adOpenStatic, adLockReadOnly
to:
myRecordset.Open SQL2, databaseConnection, adOpenStatic, adLockReadOnly