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
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