Silent Mode for DoCmd.RunSQL "INSERT INTO ... ;"

R

Ralph

Hello to all,
I have code which works well for appending a record to a table. However,
I have written the error handling code for ensuring that only acceptable
user-provided data is used to build a dynamic SQL call. And I do NOT want a
message box shown to the user, asking "... You are about to append 1
row(s)... Yes [command button]... No [command button]". When the user sees
this message box and selects, "Yes", then the code executes just fine.
However, when the user selects, "No", the a message box pops up with an
option to "Debug", and I DO NOT want the casual user having access to the
vba code for this (or any) module. How can I have the query execute in
"Silent Mode"?

TIA,
Ralph in Boise
 
A

Allen Browne

Use:
dbEngine(0)(0).Execute "INSERT INTO ...", dbFailOnError

The command executes silently, and generates an error message only if the
insert fails.

If you want to use DoCmd.RunSQL, you could SetWarnings off and turn it back
on again afterwards.
 
R

Ralph

Allen,
Thank you for the great tip. I successfully used both methods in very
little time at all.

Ralph in Boise


Allen Browne said:
Use:
dbEngine(0)(0).Execute "INSERT INTO ...", dbFailOnError

The command executes silently, and generates an error message only if the
insert fails.

If you want to use DoCmd.RunSQL, you could SetWarnings off and turn it back
on again afterwards.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ralph said:
Hello to all,
I have code which works well for appending a record to a table. However,
I have written the error handling code for ensuring that only acceptable
user-provided data is used to build a dynamic SQL call. And I do NOT
want
a
message box shown to the user, asking "... You are about to append 1
row(s)... Yes [command button]... No [command button]". When the user sees
this message box and selects, "Yes", then the code executes just fine.
However, when the user selects, "No", the a message box pops up with an
option to "Debug", and I DO NOT want the casual user having access to the
vba code for this (or any) module. How can I have the query execute in
"Silent Mode"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top