473,385 Members | 2,269 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,385 software developers and data experts.

DefQuery: How to use key word "AS" to create string for sql property

Hi Experts,

I have a general question.

I want to create a string (in VBA) for the sql property of a DefQuery
Object. But I don't know how to include expressions like the key word
--> AS <-- and --> " " <--.

I tried it with --> ' ' <--, but without success.

Examples which I would like to integrate:

string = "select [2003] AS ACTUAL, [2002] AS LAST_YEAR ...

.... between "aa" and "ee" ........

Thanks in advance for your help.

Kind regards,
Hannes

Nov 12 '05 #1
3 1488
There should be no problem with AS within the string.
To embed quote marks in the string, double them up, e.g.:

Dim strSql As String

strSQL = "SELECT [2003] AS Actual FROM MyTable WHERE ([MyCategoryField]
Between ""a"" And ""ezzz"");"

CurrentDb().QueryDefs("MyQuery").SQL = strSQL

--
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.

"Hannes S" <hs******@gmx.at> wrote in message
news:40**************@news.utanet.at...
Hi Experts,

I have a general question.

I want to create a string (in VBA) for the sql property of a DefQuery
Object. But I don't know how to include expressions like the key word
--> AS <-- and --> " " <--.

I tried it with --> ' ' <--, but without success.

Examples which I would like to integrate:

string = "select [2003] AS ACTUAL, [2002] AS LAST_YEAR ...

.... between "aa" and "ee" ........

Thanks in advance for your help.

Kind regards,
Hannes

Nov 12 '05 #2
Hi Allen,

The problem with --> AS <-- was, that VBA always told me, that it
expects an end of the instruction. But perhaps it's something else
(like a missing question mark) I will try it again with a more simple
syntax.

Thanks for the hints regarding the question marks. I will try it
during the day.

Greetings from Austria to Australia
Hannes
On Wed, 28 Jan 2004 09:42:10 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
There should be no problem with AS within the string.
To embed quote marks in the string, double them up, e.g.:

Dim strSql As String

strSQL = "SELECT [2003] AS Actual FROM MyTable WHERE ([MyCategoryField]
Between ""a"" And ""ezzz"");"

CurrentDb().QueryDefs("MyQuery").SQL = strSQL

--
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.

"Hannes S" <hs******@gmx.at> wrote in message
news:40**************@news.utanet.at...
Hi Experts,

I have a general question.

I want to create a string (in VBA) for the sql property of a DefQuery
Object. But I don't know how to include expressions like the key word
--> AS <-- and --> " " <--.

I tried it with --> ' ' <--, but without success.

Examples which I would like to integrate:

string = "select [2003] AS ACTUAL, [2002] AS LAST_YEAR ...

.... between "aa" and "ee" ........

Thanks in advance for your help.

Kind regards,
Hannes



Nov 12 '05 #3
An****************@See.Comment.Header (Jim's wife) wrote:
Comments: This message did not originate from the above address.
It was remailed by two or more anonymous mail services.


As always if you see a posting which looks somewhat bizarre check the headers.

Please ignore this posting.

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 12 '05 #4

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

Similar topics

68
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I...
4
by: MLH | last post by:
The following function declaration confuses me... Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef sReason As String) As Boolean I tried pasting it and its code into an...
5
by: Hayato Iriumi | last post by:
When converting a type to another using CType and if the type conversion fails, it throw an exception. However, in C#, there is a keyword "as" which only makes the variable Nothing (null) without...
2
by: Prabhudhas Peter | last post by:
I need a ComboBox property like "ItemData" in VB.Net as in VB 6.0. The Idea behind this question is, i've created a user control combo box in vb.net with my own set of properties..now i want to...
2
by: sherifffruitfly | last post by:
Hi, I'm using an adaptation of excel-reading code that's all over the internet - I don't much like or understand it, but it has worked for me in the past.... beggars can't be choosers... : ...
2
by: shawncraig | last post by:
I'm sure I'm just missing something here but is there a way to nest objects inside an object or a collection that functions like an object with properties BESIDES creating whole classes or making...
11
by: arnuld | last post by:
C takes input character by character. I did not find any Standard Library function that can take a word as input. So I want to write one of my own to be used with "Self Referential Structures" of...
209
by: arnuld | last post by:
I searched the c.l.c archives provided by Google as Google Groups with "word input" as the key words and did not come up with anything good. C++ has std::string for taking a word as input from...
5
by: gflor16 | last post by:
Problem: I have this code to run a word counter. But I have a problem when I hit the enter key, it doesn't give me any output of how many chars or words. ''' <summary> ''' Returns Word...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.