Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
String Building for Where Clause in query [email protected] Excel Programming 2 June 25th 07 10:54 PM
String Building for Where Clause in Query [email protected] Excel Programming 0 June 7th 07 12:43 PM
Building a string [email protected] Excel Programming 3 September 25th 06 09:53 AM
Building Sum by Matching String guruk Excel Discussion (Misc queries) 1 July 10th 06 12:55 PM
Help building string for Names.Add RefersTo, pls? Ed Excel Programming 10 April 7th 05 05:00 PM


All times are GMT +1. The time now is 05:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"