Turning off query prompts on runtime version of Access 2016

Hi - For some reason, I cannot seem to switch off prompts to run existing Update/Delete queries (either stored queries or queries created on the fly).  I used to use something like this - but it no longer seems to work.

Application.SetOption "Confirm Action Queries", 0
Application.SetOption "Confirm Document Deletions", 0
Application.SetOption "Confirm Record Changes", 0

Any ideas?
Andy BrownDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
Hi Andy,

rather than using DoCmd to execute a query, use
CurrentDb.Execute "MyQueryName"

Open in new window

Then you won't have to bother with the settings and it is better performance.

Instead of CurrentDb, you can use an object variable. For instance:
dim db as Dao.Database
set db = CurrentDb
db.Execute "MyQueryName1"
db.Execute "MyQueryName2"
set db = nothing

Open in new window

if a query you are running depends on the results of a previous query, before executing, refresh the tables and follow with DoEvents:

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andy BrownDeveloperAuthor Commented:
Thanks Crystal - I'm seeing a lot of suggestions to go that way (so I'm going to take a look at the code now).

Just out of curiosity - Do you know if they stopped providing those setup options, as I can't seem them anywhere now?

Anyhow, thanks again - very much appreciated.
Dale FyeOwner, Dev-Soln LLCCommented:
no points please.

Strongly agree with Crystal, better to use the Execute method than either:

Open in new window


Open in new window

Personally, I like to add the dbFailOnError as an option so that I can record any errors that might occur and process them properly.
db.Execute "YourQueryName", dbFailOnError

Open in new window

But when you do this, you must have an error handler (you should anyway) to deal with any errors.
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you're welcome, Andy

not being able to change the setup options may have something to do with permissions and where files are located. I have not done testing to know what might have changed.

dbFailOnError -- Dale brought this up and it needs consideration -- this is something that needs to be evaluated on a case-by-case basis.  For example, most of the append queries I run only add new records due to unique indexes not allowing duplicates to go in -- in those cases, I do want the rest of the records that are ok to go in, so I would not want the SQL to fail because some of the records didn't make it. (The Append query might be followed by an Update query to change the records that were already there).  To tell me if  the SQL itself has an error, I have code to run SQL statements that also returns how many records were changed.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.