In the following query, 1. I am getting a syntax error of missing operator starting on line 4 of the query starting with t1.Mon = t2.Sort INNER JOIN.... I have tried with and without adding parenthesis but can't seem to fine the right combination, if that truly is the issue. 2. How do you code the query to pass in the variable prmMarketValue? Lines 6 & 7 of the query are commented until issue 1 is resolved.
If PVF_Type = "SCH" Then
For i = 1 To 2
prmMarket_Value = i
'CurrentDb.QueryDefs.Delete "Q10All_SCH_StaffResults"
sSql = "SELECT t1.PVF, t1.Market, t1.Manager, t1.Supervisor, t1.Sch_Q3,t1.Corp_ID, t2.Month, t1.Score " _
&"INTO t75_StaffResults " _
& "FROM (t10_PreVisit_Import_Scores t1 INNER JOIN " _
& "t99MonthSort t2 ON t1.Mon=t2.Sort " _
& "INNER JOIN t99Market t3 ON t1.Market = t3.Market "
'& "WHERE t1.PVF = [Forms]![f03Reports]![cmbPVFsel] " _
'& "AND t3.Market_Value) = prmMarket_Value"
MsgBox (sSql)
SetQDef = CurrentDb.CreateQueryDef("Q10All_SCH_StaffResults" , sSql)
DoCmd.OpenQuery "Q10All_SCH_StaffResults"