[AccessD] DoCmd.RunSQL or CurrentDb.Execute?

Stuart McLachlan stuart at lexacorp.com.pg
Tue Jan 6 16:40:19 CST 2004


On 7 Jan 2004 at 8:22, David Fenton wrote:

> 
> Quick question...
> Which is better to use?
> Assuming an SQL string in a variable called strSQL
> Then...
> 
> DoCmd.RunSQL strSQL
> Or
> CurrentDb.Execute strSQL
> 
> They both have the same outcome; I was just wondering whether one was
> maybe faster or something?
> 

WIth DoCmd.RunSQL, you get the standard messagebox 'You are about 
to...." 

If you want the update to happen without any user action, use  
CurrentDB.Execute. If you want the warning and  the user to have the 
opportunity to cancel the action, user DoCmd.RunSQL 

Note that  
"DoCmd.SetWarnings False
 DoCmd.RunSQL strSQL
 DoCmdSetWarnings True"

suppresses the update notice, but also has the effect of suppressing 
any error messages generated by a problem in strSQL.

 
-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System 
Support.





More information about the AccessD mailing list