What does the & _ symbols represent in an SQL statement?
e.g.
strSQL = "SELECT name, age FROM table WHERE " & _
"name = '" &name& "'"
Why are they in separate lines and what is the function of the "& _" symbol represented above?
Printable View
What does the & _ symbols represent in an SQL statement?
e.g.
strSQL = "SELECT name, age FROM table WHERE " & _
"name = '" &name& "'"
Why are they in separate lines and what is the function of the "& _" symbol represented above?
The & _ is not part of the SQL statement. All that does is allow you to spread a statement over more than one line.
This
Is the same as thisCode:
strSomeString = "some text in a string"
strSomeString = strSomeString & "more text for the string"
strSomeString = strSomeString & "yet more text"
Code:
strSomeString = "some text in a string" & _
"more text for the string" & _
"yet more text"
"name = '"&name&"'"
it means that the second name ('"&name&"') is parameter
eg.
name = &_
inputbox("Enter Your name ? ")
strSQL = "SELECT name, age FROM table WHERE" &_
"name = '"&name&"'"
data1.recordsource = strsql
it means that data1 recordsource will contain records which has name same with the name that you enter through the inputbox.
thanks
bambang
Hi there,
1.)
you can use a & to join two strings:
e.g.
string1 = "Hello "
string2 = "World!"
newstring = string1 & string2 '--> "Hello World"
2.)
with the underscore _ you can insert a linebreak into your code without VB complaining about it
however there has to be a space before the underscore
e.g.
without the underscore VB would complainCode:if (condition2 or condition2) and condition3 _
then dowhateveryouwant