PC Review


Reply
Thread Tools Rate Thread

Building SQL-string with vba

 
 
Jan T.
Guest
Posts: n/a
 
      5th Jun 2008
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      6th Jun 2008
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." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
 
Jan T.
Guest
Posts: n/a
 
      11th Jun 2008
Ah, of course! I just couldn't remember.
Thanks a lot!
'*'

Jan


"Bob Phillips" <(E-Mail Removed)> skrev i melding
news:(E-Mail Removed)...
> 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." <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with sql string building Jack Microsoft Access Queries 2 13th Nov 2009 11:14 PM
Building A string dmoney Microsoft Excel Programming 1 1st Oct 2009 05:15 AM
building a string Dave Microsoft Access VBA Modules 3 18th May 2008 09:46 PM
Is KeyValuePair<string,string>.ToString intended as serialization building block? Steve Richter Microsoft C# .NET 2 7th May 2007 09:34 PM
Building an SQL query string to include "&" as part of string Paul Microsoft Access VBA Modules 4 27th Aug 2003 09:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:52 AM.