Spaces in SQL Statement

dynamictiger

Registered User.
Local time
Today, 13:56
Joined
Feb 3, 2002
Messages
270
This is SQL statement I want to manipulate in VBA:

"SELECT [ClientName] & " "& [PoolAddress] AS ClientDetail, " & _
"[FirstName] & " " & [LastName] AS ClientName, [StreetNumber] " & _
" " & [StreetName] & " " & [RoadType] & " "& [Locality] & " " & " & _
"[PCode] AS PoolAddress, tblServJob.JobDate, tblServJob.TimePromised, " & _
"tblServJob.AllocatedTime, tblServPerson.ServicePerson, " & _
"tblServJob.JobDescription " & _ etc

As you can see there are spaces all through it. How do I make this work in VBA?
 
Try this:

"SELECT [ClientName] & " " & [PoolAddress] AS ClientDetail, " & _
"[FirstName] & " " & [LastName] AS ClientName, [StreetNumber] " & _
"& " " & [StreetName] & " " & [RoadType] & " " & [Locality] & " " & " & _
"[PCode] AS PoolAddress, tblServJob.JobDate, tblServJob.TimePromised, " & _
"tblServJob.AllocatedTime, tblServPerson.ServicePerson, " & _
"tblServJob.JobDescription FROM tblServJob;"

shay :cool:
 
In code you can use a pair of single quotes or a pair of two consecutive double quotes to enclose the space, that is:


SQL="SELECT [ClientName] & ' ' & [PoolAddress] AS ClientDetail, " & _

Or,

SQL="SELECT [ClientName] & "" "" & [PoolAddress] AS ClientDetail, " & _
 

Users who are viewing this thread

Back
Top Bottom