RunSQL versus the Db.execute command

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

These two statments seem to do the same thing, Please let me know why you
would use one over the other?

Thanks,

Kerry
 
Execute lets you trap errors if you specify dbFailOnError as a parameter. It
also doesn't have the user prompts like "You are about to update n
records.".
 
KSH said:
These two statments seem to do the same thing, Please let me know why
you would use one over the other?

Thanks,

Kerry

The main differences are that RunSQL (a) lets Access evaluate the SQL
statement and fill in the values for any references to form controls,
and (b) normally displays a confirmation warning about the records that
will be affected by the statement and giving the user a chance to abort
it. The DAO Execute method does neither. With .Execute, you must
resolve all parameter references yourself, and no warnings are given.
Also, if the statement fails, you get no notice unless you use the
dbFailOnError argument to cause a trappable error to be raised.
 
KSH said:
These two statments seem to do the same thing, Please let me know why you
would use one over the other?

Also performance can be significantly different between the two
methods. One posting stated currentdb.execute took two seconds while
docmd.runsql took eight seconds. As always YMMV.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 

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

Similar Threads


Back
Top