String variable containing a quoted space

C

charles.kendricks

I am trying to create a string variable from an SQL query that
contains a quoted space. The query is as follows:

INSERT INTO tblBirthday ( CustID, WholeName, Address, City, Statee,
Zip, Birthdate )
SELECT tblCustomer.CustID, [FName] & " " & [LName] AS WholeName,
PCase([Addr]) AS Address, PCaseCity([Cty]) AS City, UCase([State]) AS
Statee, tblCustomer.Zip, tblCustomer.Birthdate
FROM tblCustomer
WHERE (((DatePart("m",[Birthdate]))=4) AND ((DatePart("d",
[BirthDate])) Between 10 And 10+6) AND ((tblCustomer.BadAdx)=False)
AND ((tblCustomer.BCardSent)=False));

I am taking pieces of the query and assigning them to the variable
strQry as such:

Dim strSql As String
strSql = "INSERT INTO tblBirthday ( CustID, WholeName, Address, City,
Statee,"
strSql = strSql & " Zip, Birthdate ) SELECT tblCustomer.CustID,
[FName] & " " & [LName]"

However this is where I run into trouble. I keep getting an "Expected
end Statement" error and I know it's due the the double quoted space
in the variable string, but I don't know how to remedy the problem
 
J

John Spencer

Simplest method is to DOUBLE up on the quotes
strSql = "INSERT INTO tblBirthday ( CustID, WholeName, Address, City,
Statee,"
strSql = strSql & " Zip, Birthdate ) SELECT tblCustomer.CustID,
[FName] & "" "" & [LName]"


'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top