473,499 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

runsql vs Execute

What's better/ faster/ more efficient. Using Docmd.RunSql or Execute
to run sql? When is one better than the other or inappropriate to use?

Thanks.

jim
Nov 13 '05 #1
7 5081
Execute (DAO) has several advantages, e.g.:
- Does not need you to turn off SetWarnings.
- The dbFailOnError switch lets you know if it worked or not;
- You can use it with transactions, to roll back after a problem. Example:
http://members.iinet.net.au/~allenbrowne/ser-37.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jimmer" <jr*****@hotmail.com> wrote in message
news:70*************************@posting.google.co m...
What's better/ faster/ more efficient. Using Docmd.RunSql or Execute
to run sql? When is one better than the other or inappropriate to use?

Thanks.

jim

Nov 13 '05 #2
Thanks.

I presume that excluding the Setwarnings statement. The execution time is the same?

Thanks again.

Jim.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41***********************@per-qv1-newsreader-01.iinet.net.au>...
Execute (DAO) has several advantages, e.g.:
- Does not need you to turn off SetWarnings.
- The dbFailOnError switch lets you know if it worked or not;
- You can use it with transactions, to roll back after a problem. Example:
http://members.iinet.net.au/~allenbrowne/ser-37.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jimmer" <jr*****@hotmail.com> wrote in message
news:70*************************@posting.google.co m...
What's better/ faster/ more efficient. Using Docmd.RunSql or Execute
to run sql? When is one better than the other or inappropriate to use?

Thanks.

jim

Nov 13 '05 #3
Thanks. I presume that with the exception of the setwarnings
statement, the processing time is the same?

Thanks.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41***********************@per-qv1-newsreader-01.iinet.net.au>...
Execute (DAO) has several advantages, e.g.:
- Does not need you to turn off SetWarnings.
- The dbFailOnError switch lets you know if it worked or not;
- You can use it with transactions, to roll back after a problem. Example:
http://members.iinet.net.au/~allenbrowne/ser-37.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jimmer" <jr*****@hotmail.com> wrote in message
news:70*************************@posting.google.co m...
What's better/ faster/ more efficient. Using Docmd.RunSql or Execute
to run sql? When is one better than the other or inappropriate to use?

Thanks.

jim

Nov 13 '05 #4
Try it and see.

I doubt there will be much difference. Other factors are likely to loom
larger, such as whether the data is in cache, whether you are using
transactions, network traffic (if the data is on a server), ...

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jimmer" <jr*****@hotmail.com> wrote in message
news:70**************************@posting.google.c om...
Thanks. I presume that with the exception of the setwarnings
statement, the processing time is the same?

Thanks.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:<41***********************@per-qv1-newsreader-01.iinet.net.au>...
Execute (DAO) has several advantages, e.g.:
- Does not need you to turn off SetWarnings.
- The dbFailOnError switch lets you know if it worked or not;
- You can use it with transactions, to roll back after a problem.
Example:
http://members.iinet.net.au/~allenbrowne/ser-37.html

"Jimmer" <jr*****@hotmail.com> wrote in message
news:70*************************@posting.google.co m...
> What's better/ faster/ more efficient. Using Docmd.RunSql or Execute
> to run sql? When is one better than the other or inappropriate to use?
>
> Thanks.
>
> jim

Nov 13 '05 #5
jr*****@hotmail.com (Jimmer) wrote:
Thanks. I presume that with the exception of the setwarnings
statement, the processing time is the same?


One person stated in testing one particular update that Execute took 2 seconds while
docmd.runsql took 8 seconds. 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
Nov 13 '05 #6
jr*****@hotmail.com (Jimmer) wrote in message news:<70**************************@posting.google. com>...
Thanks. I presume that with the exception of the setwarnings
statement, the processing time is the same?

Thanks.


No idea. Put a timer on your form and execute each one something like
10,000 times in a loop. Use GetTickCount and you'll have your answer.
Nov 13 '05 #7
Jimmer wrote:
What's better/ faster/ more efficient. Using Docmd.RunSql or Execute
to run sql? When is one better than the other or inappropriate to use?

Thanks.

jim


RunSQL gives you nice progress meter, if the query is not very complex
then it's quite accurate :-)

--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10170
by: Rotsj | last post by:
Hi, i try to execute an update query from within a form, but i get the message: run time error '3144'. Syntax error on the update statement when i try something like this: DoCmd.RunSQL...
19
424
by: DCM Fan | last post by:
Access 2000/Windows 2000 Pro with all current updates on the client; SQL Server 7.0/Windows 2000 Server with all current updates on the server. Bottom line: In a certain context dbs.Execute...
3
1874
by: DCM Fan | last post by:
All, A month or so ago I started a thread titled "I was *forced* to use RunSQL." At that time, I said I'd get back to you after trying the dbSeeChanges constant in the Execute method. I was...
7
4264
by: Richard Hollenbeck | last post by:
Help! I don't know why this isn't working: Private Sub Combo9_Change() Dim UsersCourseSelection As String UsersCourseSelection = Me("Combo9").Value Combo13.Visible = True 'the following...
8
11200
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
2
5691
by: ben | last post by:
I have the following code in a VBA module: DoCmd.RunSql "Update tData Set sd = Log(Strike/Price) where symbol = '" & symbol & "'" This statement worked fine, and was using the built in math...
1
4075
by: TriednTested | last post by:
Hello I have a subform and to edit the data I place it on the main form where changes can be made, then a cmd button is used to execute the docmd.runsql update query. However I am constantly getting...
2
2724
by: Trish | last post by:
I have been trying to create a local table from a linked Excel Spreadsheet using a simple query string like this: SELECT * INTO LocalTable FROM LinkedExcelSheet; If I use CurrentDB.Execute, I...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.