DoCmn.RunSQL versus CurrentDb.Execute

bvanscoy678

New member
Local time
Today, 15:17
Joined
Apr 2, 2015
Messages
4
Hello,

Is there any particular reason I would choose to use

DoCmd.RunSQL "insert into...

Versus

CurrentDb.Execute "insert into.... ??

I am using an unbound form on the front end of my database to populate the backend tables (multiple tables). Some forms only have a few fields, while other forms have about 15 fields with 3-4 tables updating.

I am okay using the DoCmn.RunSQL , but I keeping reading on the forum that others chose CurrentDB.Execute and it has me thinking.

My database is stored on a network drive with only on front end.

Thanks
Brent
 
RunSQL will raise warnings (Insert, Delete and Update) unless you turn them off. However if you do turn them off, errors such as key violations will be ignored.

Execute does not raise warnings. If you include dbFailOnError as the second argument it will raise an error if there are any problems such as key violations.

RunSQL is preprocessed by Access so it understands references to Access objects such as controls on forms.

Execute is sent directly to the database engine so cannot interpret Access objects. Any such values must be concatenated into the SQL command along with the appropriate delimiters.
 
This explains quite a bit of the threads I read on the errors of incorrect syntax on their execute commands.

Thanks for the information. Very helpful.

Brent
 

Users who are viewing this thread

Back
Top Bottom