What’s the difference between DoCmd.SetWarnings and CurrentDB.Execute

They do not both mask errors. DoCmd.SetWarnings masks errors and is system wide, not confined to the single application that you are using. DoCmd.SetWarnings False without the corresponding DoCmd.SetWarnings True will mean that action queries will run without any prompts in any Access application on the PC.

Execute does throw warnings, the warnings that you need, such as the query failed to execute, but does not give warnings you may not need, such as “Are you sure you want to run this query”.

In this thread Allen Browne, Access MVP, says he does not use Set Warnings.

As an aside, I would generally recommend using an instance of CurrentDB, as this will allow you to return a record count, amongst other things, so:

Set db = CurrentDB
db.Execute sSQL, dbFailOnError

Leave a Comment