LarryDeLaruelle
Technical User
I'm trying to create a query in SQL and concantenate several fields (to set up a mailing file). I created the query in QBE and then cut and pasted the code to my module.
I am getting this error message at the point where I am doing the CreateQueryDef:
Syntax Error (missing operator) in query expression 'Prefix FirstName LastName Suffix'
Here is my code:
strSQL = "SELECT DISTINCT Prefix " & " " & "FirstName " & " " & "LastName " & " " & "Suffix AS Name, " _
& "tblContacts.JobTitle, tblAgency.AgencyName, tblContacts.MailStop, tblAgency.MailAddress, " _
& "City " & " " & "StateCode " & " " & "tblZipCodes.ZipCode AS Address " _
& "FROM tblZipCodes INNER JOIN (tblAgency INNER JOIN tblContacts ON tblAgency.AgencyID = " _
& "tblContacts.AgencyID) ON tblZipCodes.ZipCode = tblAgency.ZipCode " _
& "WHERE (((tblContacts.Calendar)=Yes));"
What am I doing wrong with the concantenation part of the string? Obviously, I'm missing something but can't figure out what.
Thanks in advance.
Larry De Laruelle
larry1de@yahoo.com
I am getting this error message at the point where I am doing the CreateQueryDef:
Syntax Error (missing operator) in query expression 'Prefix FirstName LastName Suffix'
Here is my code:
strSQL = "SELECT DISTINCT Prefix " & " " & "FirstName " & " " & "LastName " & " " & "Suffix AS Name, " _
& "tblContacts.JobTitle, tblAgency.AgencyName, tblContacts.MailStop, tblAgency.MailAddress, " _
& "City " & " " & "StateCode " & " " & "tblZipCodes.ZipCode AS Address " _
& "FROM tblZipCodes INNER JOIN (tblAgency INNER JOIN tblContacts ON tblAgency.AgencyID = " _
& "tblContacts.AgencyID) ON tblZipCodes.ZipCode = tblAgency.ZipCode " _
& "WHERE (((tblContacts.Calendar)=Yes));"
What am I doing wrong with the concantenation part of the string? Obviously, I'm missing something but can't figure out what.
Thanks in advance.
Larry De Laruelle
larry1de@yahoo.com