VB Syntax Question

bella

Registered User.
Local time
Today, 21:57
Joined
Jul 31, 2003
Messages
38
Hi, sorry for this very dumb question but:

Cam some1 please tell me what the following operators refer to in VB, and how to use them. I am getting syntax errors so I must be doing something wrong.

when do you use ' in an SQL expression?

when do you use " in an SQL expression?

When do you use both " and ' in an SQL expression?

>banging head on desk in frustration<

Bella:(
 
" and ' are both string delimiters.

An SQL expression in VBA is written as a string eg

"SELECT *FROM AnyTable"

If you want to add criteria i.e. a WHERE clause you write:

"SELECT *FROM AnyTable WHERE MyText field ="

and then you scratch your head and say, "yeah but my text field's a string as well!"

so you then use the ' delimiter so Access doesn't get confused.

"SELECT *FROM AnyTable WHERE MyText field ='" & MyTextField and "'"

When the code is interpreted, the double quotes are stripped to give a statement that reads:

SELECT *FROM AnyTable WHERE MyText field ='AValue'

Yes, it's confusing, I agree. There are ways of making the whole shebang less confusing though Look here for a better explanation by a well-known authority.

http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=52762
 

Users who are viewing this thread

Back
Top Bottom