Link to home
Get AccessLog in
Avatar of Andy Brown
Andy BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

Link to home
membership
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access
Avatar of Andy Brown

ASKER

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.
no points please.

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

Open in new window

or:
docmd.OpenQuery

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.
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

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.