Question strSQL = Run Time Error 3075 Syntax Error Missing Operator in qry Expr (1 Viewer)

maxsun08

Registered User.
Local time
Today, 09:20
Joined
Jul 27, 2012
Messages
15
Hello all,

I've come across a simple error that has me baffled. I continue to receive the run time error 3075: Syntax error (missing operator) in query expression
'tblMasterPersonnel.FirstName"042" Or
(tblMasterPersonnel.EmpID)="044"))'

Here is the strSQL

Code:
strSQL = " SELECT tblMasterPersonnel.EmpID, qryiuSSN.SSN, ""SSN"" AS [ID Type], """" AS TXN, tblMasterPersonnel.LastName, " & _
        "tblMasterPersonnel.FirstName, tblMasterPersonnel.MI, """" AS Suffix, IIf([tblMasterPersonnel].[Gender]=True,""F"",""M"") AS Gender, " & _
        "tblMasterPersonnel.Birthday, tblMasterPersonnel.PlaceBirth, """" AS [Country Code], """" AS Country, tblAddresses.Phone1, " & _
        "tblAddresses.Street, tblAddresses.City, tblAddresses.State, tblAddresses.Zip, tblAddresses.Country, " & _
        "tblMasterPersonnel.EmailAddress, """" AS [Contract End] " & _
" FROM (tblMasterPersonnel LEFT JOIN tblAddresses ON tblMasterPersonnel.EmpID = tblAddresses.EmpID) " & _
" LEFT JOIN qryiuSSN ON tblMasterPersonnel.EmpID = qryiuSSN.EmpID " & _
" WHERE ((([tblAddresses].[AddressType]) = ""0"") And (([tblMasterPersonnel].[CurrentSite]) <> ""Not Employed"" And ([tblMasterPersonnel].[CurrentSite]) <> ""Medical-Long Term"")) " & _
" ORDER BY tblMasterPersonnel.LastName, tblMasterPersonnel.FirstName"""

Debug.Print strSQL
Any ideas?
 

PaulO

Registered User.
Local time
Today, 07:20
Joined
Oct 9, 2008
Messages
421
Have you simply omitted an "=" sign?

Current coding:
'tblMasterPersonnel.FirstName"042" Or
(tblMasterPersonnel.EmpID)="044"))'

Amended coding:
'tblMasterPersonnel.FirstName="042" Or
(tblMasterPersonnel.EmpID)="044"))'
 

maxsun08

Registered User.
Local time
Today, 09:20
Joined
Jul 27, 2012
Messages
15
Hi Paulo,

Sincere thanks for helping. I included = in ORDER BY as follows:

Code:
" ORDER BY tblMasterPersonnel.LastName, (tblMasterPersonnel.FirstName)="""

Which now produces the following error:
Run Time error 3075

Extra ) in query expression
'(tblMasterPersonnel.FirstName)="042" Or
(tblMAsterPersonnel.EmpID)="044"))'.

I can't find where this extra ) is. Also, the value 042 is an EmpID and should reflect a first name.
 

PaulO

Registered User.
Local time
Today, 07:20
Joined
Oct 9, 2008
Messages
421
'(tblMasterPersonnel.FirstName)="042" Or
(tblMAsterPersonnel.EmpID)="044"))'.

Try removing the last ")", as above, possibly even the one before as well ...
 

maxsun08

Registered User.
Local time
Today, 09:20
Joined
Jul 27, 2012
Messages
15
Appreciate the assist Paulo but no luck. Going to try another approach, would you happen to know how to export selected items in a list box to excel using VBA?

Cheers
 

Users who are viewing this thread

Top Bottom