Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Building SQL-string with vba
Here is what I want to put into a variabel; strSQL.
However, I am experiencing some difficulties whith the spaces. What do I do wrong? I copied this from my Query-builder in Access 2000. ---------------------------------------------------------------- SELECT [Firstname] & " " & [Lastname] AS Employee FROM Employees WHERE ((([Firstname] & " " & [Lastname]) Like [Forms]![myForm].[txtName] & "*")); I tried different combinations of ", """, """" """", "'" "'" and so on... Like...: strSQL = "SELECT [Firstname] & "'" "'" & [Lastname] AS Employee" strSQL = strSQL & " FROM Employees" strSQL = strSQL & " WHERE ((([Firstname] & "'" "'" & [Lastname]) Like [Forms]![myForm].[txtName] & '*'));" But, as you might see, this fails. Any suggestions? Thank you in advance! Regards Jan |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Building SQL-string with vba
How about
"SELECT [Firstname] &' ' & [Lastname] AS Employee " & _ "FROM Employees " & _ "WHERE ((([Firstname] & ' ' & [Lastname]) Like [Forms]![myForm].[txtName] & "*"));" -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Jan T." wrote in message ... Here is what I want to put into a variabel; strSQL. However, I am experiencing some difficulties whith the spaces. What do I do wrong? I copied this from my Query-builder in Access 2000. ---------------------------------------------------------------- SELECT [Firstname] & " " & [Lastname] AS Employee FROM Employees WHERE ((([Firstname] & " " & [Lastname]) Like [Forms]![myForm].[txtName] & "*")); I tried different combinations of ", """, """" """", "'" "'" and so on... Like...: strSQL = "SELECT [Firstname] & "'" "'" & [Lastname] AS Employee" strSQL = strSQL & " FROM Employees" strSQL = strSQL & " WHERE ((([Firstname] & "'" "'" & [Lastname]) Like [Forms]![myForm].[txtName] & '*'));" But, as you might see, this fails. Any suggestions? Thank you in advance! Regards Jan |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Building SQL-string with vba
Ah, of course! I just couldn't remember.
Thanks a lot! '*' Jan "Bob Phillips" skrev i melding ... How about "SELECT [Firstname] &' ' & [Lastname] AS Employee " & _ "FROM Employees " & _ "WHERE ((([Firstname] & ' ' & [Lastname]) Like [Forms]![myForm].[txtName] & "*"));" -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Jan T." wrote in message ... Here is what I want to put into a variabel; strSQL. However, I am experiencing some difficulties whith the spaces. What do I do wrong? I copied this from my Query-builder in Access 2000. ---------------------------------------------------------------- SELECT [Firstname] & " " & [Lastname] AS Employee FROM Employees WHERE ((([Firstname] & " " & [Lastname]) Like [Forms]![myForm].[txtName] & "*")); I tried different combinations of ", """, """" """", "'" "'" and so on... Like...: strSQL = "SELECT [Firstname] & "'" "'" & [Lastname] AS Employee" strSQL = strSQL & " FROM Employees" strSQL = strSQL & " WHERE ((([Firstname] & "'" "'" & [Lastname]) Like [Forms]![myForm].[txtName] & '*'));" But, as you might see, this fails. Any suggestions? Thank you in advance! Regards Jan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
String Building for Where Clause in query | Excel Programming | |||
String Building for Where Clause in Query | Excel Programming | |||
Building a string | Excel Programming | |||
Building Sum by Matching String | Excel Discussion (Misc queries) | |||
Help building string for Names.Add RefersTo, pls? | Excel Programming |