Question for Learning: Docmd.OpenQuery versus db.Execute
Posted on 2006-03-28
I've got something bugging me, so I thought I'd throw it to the Gurus for some thoughts/advice:
I recently have been trying to incorporating the DAO execute method. It seems that for action queries, the idea that "this option generates a run-time error and rolls back all successful changes if any of the records affected are locked and can't be updated or deleted" (from microsoft help) is appealing.
Is the execute method "better" than the openquery method? I sometimes get errors when attempting to run queries with the Execute Method, such as "Too Few Parameters -- Expecting 2" or "Overflow". When I change the line of code from db.execute back to docmd.openquery, the error goes away. I don't know enough about the execute method to know how to troubleshoot, so I abandon the idea of using it.
When is the best time to use either method? Is one method preferable over another?
Thanks for your insight.