473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Question about "Quotes (') and Double-Quotes (") - Where and When to use them"

thelonelyghost
109 100+
DoCmd.RunSQL strSQL

I thought there were some restrictions on what types of SQL you could run with this command. Source

** Admin Edit **
This thread pertains to the article Quotes (') and Double-Quotes (") - Where and When to use them.
Jun 30 '10 #1

✓ answered by NeoPa

That's a good point. The reasoning behind it is that I use SELECT queries in the example SQL as these are probably the most recognisable and common SQL for most people. The least threatening if you like. It's not about the actual SQL used, but the concepts of how they are built with reference to string literals within them.

Unfortunately, SELECT queries are the least simple to execute. They are either used as the Record Source of some object or other, or saved into a QueryDef (another object of course). My intention was to avoid drawing the attention away from the concept and onto whatever is required for a particular object. Clearly in your case this has back-fired somewhat. I find such a level of attention to detail on your part quite heartening. Signs of a good approach.

I will have to see if I can find a way of ensuring no-one else considers this juxtaposition of ill-fitting examples to be a problem.

Having looked at it more deeply, I can see it runs through the article more fundamentally than I'd thought at first look. Check it out now. I hope that is fixed consistently. It was a good point to raise by the way. Reading through it again I wasn't happy with it after you pointed that out.

7 1573
NeoPa
32,556 Expert Mod 16PB
That seems to be saying you cannot use it to execute a QueryDef. QueryDefs are not types of SQL. They are database objects that contain SQL.

I'm not sure I've even understood your point to be fair, so excuse me if my reply makes little sense. Perhaps you could clarify your point.
Jun 30 '10 #2
thelonelyghost
109 100+
Apologies, allow me to clarify. First paragraph under RunSQL:
"RunSQL is a method of the DoCmd object in Microsoft Access. It is designed for DML SQL, such as UPDATE, INSERT and DELETE statements. You cannot "execute" a SELECT query so the RunSQL method will fail if you attempt to pass a select statement to it."
-- Lesandrini, Danny. "Executing SQL Statements in VBA Code." Published 20 May 2005. DatabaseJournal.com

Is this just blatantly wrong or was there a mistake/misunderstanding along the way?
Jul 1 '10 #3
NeoPa
32,556 Expert Mod 16PB
No mistake. DoCmd.RunSQL can only be used for action queries. I'm wondering where you feel the article implied otherwise. The last code snippet is an example of using SQL only. It is not intended to imply DoCmd.RunSQL specifically need be used, simply that you should do your thing with the SQL after the SQL string itself has been displayed to the Immediate Pane. Is that what the question was about? The last line?

By the way, as this is a question relative to the article rather than additions to the article itself, I'll split it into a separate Question thread (Question about "Quotes (') and Double-Quotes (") - Where and When to use them").
Jul 1 '10 #4
thelonelyghost
109 100+
I guess I felt that the article gave a faulty example. As a reminder you posted these two, which the DoCmd.RunSQL command could reference either of them.

Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM [TableName] WHERE ([AccountName]='Hieronymous')" 
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT *" & VbCrLf & _ 
  2.          "FROM [TableName]" & VbCrLf & _ 
  3.          "WHERE ([AccountName]='" & Me.cboAccount & "')" 
My original comment was mostly to point out that DoCmd.RunSQL has the restriction of not being able to use SELECT statements. It seemed that you were using the above strings as examples to put into DoCmd.RunSQL and I guess I was politely asking if you knew its limitations (to action queries) when writing the article.
Jul 1 '10 #5
NeoPa
32,556 Expert Mod 16PB
That's a good point. The reasoning behind it is that I use SELECT queries in the example SQL as these are probably the most recognisable and common SQL for most people. The least threatening if you like. It's not about the actual SQL used, but the concepts of how they are built with reference to string literals within them.

Unfortunately, SELECT queries are the least simple to execute. They are either used as the Record Source of some object or other, or saved into a QueryDef (another object of course). My intention was to avoid drawing the attention away from the concept and onto whatever is required for a particular object. Clearly in your case this has back-fired somewhat. I find such a level of attention to detail on your part quite heartening. Signs of a good approach.

I will have to see if I can find a way of ensuring no-one else considers this juxtaposition of ill-fitting examples to be a problem.

Having looked at it more deeply, I can see it runs through the article more fundamentally than I'd thought at first look. Check it out now. I hope that is fixed consistently. It was a good point to raise by the way. Reading through it again I wasn't happy with it after you pointed that out.
Jul 1 '10 #6
thelonelyghost
109 100+
Much better now. All I really wanted was a small note like that or a link to more info on how to use DoCmd.RunSQL so as not to distract from the thesis of the article. Les changes sont parfait, merci!

P.S. If you can't tell I use french when I'm happy about something. I really hope this doesn't bend the typical English-only rule too far...
Jul 1 '10 #7
NeoPa
32,556 Expert Mod 16PB
I don't think they're bent too far by your French, and I'm pleased that's resulted in a clearer, easier to understand, article. Thanks for your input :)
Jul 1 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: sang park | last post by:
Hi all - Just started learning Python this past week and had a question about using the lists in python with objects. (code attached below). basically, what i want to do is read an xml file,...
1
by: David Furey | last post by:
Hi I have an XML documnet and a XSLT document as shown below THe XSLT document brings back a filtered docmument that has the VendorName that starts with a particular sub-string This works as...
1
by: J | last post by:
Hi, Ive got 3 forms, (a subform within a subform within a form) and when I refresh the outermost form, Access closes and offers to send an error report. The forms worked fine a few weeks ago,...
1
by: charliewest | last post by:
I have a created an ASP.NET web form and custom control that generate test questions. When the user successfully answers a question, the same ASP.NET (and subsequently custom control) load itself...
8
by: Ravi Ambros Wallau | last post by:
Hey guys: What can I do when an "Error Creating Control" is displayed on the form (instead of the control), and a tooltip indicating the error never is displayed? Is there some log, some hidden...
5
by: | last post by:
Hoping someone can help with a simple but puzzling problem. I have some code that I want to build as a class method. The code works fine when I embed it in Page_Load. But when I try to generalize...
3
by: Gary | last post by:
Hi, In the program below, C = A+B, and the aim is to delay the calculation of C until the user asks for C. The boolean mUTD (UpToDate) is used indicate when Calc() must be run to make the C =...
2
by: R.A.M. | last post by:
Hello, I have started larning C# and I have a question concerning "using (...)" keyword. For example: using (SqlConnection connection = new SqlConnection(ConnectionString)) {...
2
by: Steven W. Orr | last post by:
>From the tutorial, they said that the following construct will automatically close a previously open file descriptor: ------------------- #! /usr/bin/python import sys for nn in range ( 1,...
2
by: dave | last post by:
Hi, I have searched for the answer for this error message without success. I have seen the question many times though:) I create an ASP.NET project (VS 2005, C#), and use a very simple .mdf...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.