DoCmd.run(strSQL) vs. CurrentDb.Execute (strSQL)

Willem!

Registered User.
Local time
Today, 09:07
Joined
Apr 18, 2006
Messages
50
Hi!

I have a tiny question which I am insecure about. I want to replace the following code: (the code makes a certain table empty)

Code:
DoCmd.SetWarnings False
strSQL = "DELETE FROM TestTable"
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True

by the following code:

Code:
strSQL = "DELETE FROM TestTable"
CurrentDb.Execute (strSQL)


So, in other words, can I safely leave out the SetWarnings bit in the newer code below??

Cheers,
Willem
 
No worries. Use the latter. Don't even assign the string to a variable first.
Code:
CurrentDb.Execute _
  "DELETE FROM tblAnywhere"
 
Thanks! Your shorter code is even nicer, I implement it right away :)
 

Users who are viewing this thread

Back
Top Bottom