Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error (comma) in query expression 1

Status
Not open for further replies.

Trudye

Programmer
Sep 4, 2001
932
US
I am receiving the msg: Syntax error (comma) in query expression. I am sure it's a Stevie Wonder error but I can't see it. The error denotes it is in the Where statement.

Curr_Rgn is defined as a string expression.

strSQL = "SELECT Left([NMAC DIST],2) AS Rgn_cd, EOLDLR.NMAC_SLS_DIST_CD, tblMOR_Report_Recs.NNA_Dlr, " _
& "tblMOR_Report_Recs.FSM, tblMOR_Report_Recs.Last_Access_Date, tblMOR_Report_Recs.DealerName, " _
& "tblMOR_Report_Recs.Access_Count, tblMOR_Report_Recs.RegionName, tblMOR_Report_Recs.Division, " _
& "tblMOR_Report_Recs.StartDate " _
& "FROM EOLDLR INNER JOIN tblMOR_Report_Recs ON EOLDLR.NMC_DLR_NUM = tblMOR_Report_Recs.NNA_Dlr " _
& "WHERE ((left([NMAC Dist]),2) = '" & Curr_Rgn & "') And ((tblMOR_Report_Recs.NNA_Dlr) Is Not Null) And " _
& "((EOLDLR.Status) = 'ACTIVE') " _
& "ORDER BY EOLDLR.NMAC_SLS_DIST_CD, tblMOR_Report_Recs.NNA_Dlr;"

Any Ideas?

Thanx,
Trudye
 
Code:
strSQL = "SELECT Left([NMAC DIST],2) AS Rgn_cd, EOLDLR.NMAC_SLS_DIST_CD, tblMOR_Report_Recs.NNA_Dlr, " _
& "tblMOR_Report_Recs.FSM, tblMOR_Report_Recs.Last_Access_Date, tblMOR_Report_Recs.DealerName, " _
& "tblMOR_Report_Recs.Access_Count, tblMOR_Report_Recs.RegionName, tblMOR_Report_Recs.Division, " _
& "tblMOR_Report_Recs.StartDate " _
& "FROM EOLDLR INNER JOIN tblMOR_Report_Recs ON EOLDLR.NMC_DLR_NUM = tblMOR_Report_Recs.NNA_Dlr " _
& "WHERE ((left([NMAC Dist][COLOR=red yellow] [/color],2[COLOR=red yellow])[/color]) = '" & Curr_Rgn & "') And ((tblMOR_Report_Recs.NNA_Dlr) Is Not Null) And " _
& "((EOLDLR.Status) = 'ACTIVE') " _
& "ORDER BY EOLDLR.NMAC_SLS_DIST_CD, tblMOR_Report_Recs.NNA_Dlr;"
[/code]

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Hi Trudye!

Try this:

& "WHERE Left([NMAC Dist],2) = '" & Curr_Rgn & "' And tblMOR_Report_Recs.NNA_Dlr Is Not Null And " _
& "EOLDLR.Status = 'ACTIVE' " _
& "ORDER BY EOLDLR.NMAC_SLS_DIST_CD, tblMOR_Report_Recs.NNA_Dlr;"

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
BINGO Jeff, you hit the nail on the head. So it wasn't a Stevie Wonder, it was truly my syntax that was wrong.

Thanks so much to both of you for responding.

Trudye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top