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

  • Thread starter Thread starter Ralph
  • Start date Start date
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
 
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,
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"?
 
Back
Top