Insert Into

  • Thread starter Thread starter cskester
  • Start date Start date
C

cskester

Please help with syntax error. Thank you

DoCmd.RunSQL "INSERT INTO [Monthly Sales]( DISTRIBUTOR,
SLSLNO, SLSLNO_NEW, SLSLNM, SALES, SALES_MO )SELECT
Distributors.Distributor, [qrySelect Distributors].SLSLNO,
[qrySelect Distributors].SLSLNO AS slslno_NEW, [qrySelect
Distributors].SLSLNM, Sum([SLBUSA]*[SLIVQT]) AS SALES, Left
([qrySelect Distributors].[SLIVDT],6) AS Sales_Mo FROM
[qrySelect Distributors] INNER JOIN Distributors ON
[qrySelect Distributors].SLCUNO = Distributors.DistNo
GROUP BY Distributors.Distributor, [qrySelect
Distributors].SLSLNO, [qrySelect Distributors].SLSLNO,
[qrySelect Distributors].SLSLNM, Left([qrySelect
Distributors].[SLIVDT],6) HAVING ((([qrySelect
Distributors].SLSLNM) Not Like "*house*" And ([qrySelect
Distributors].SLSLNM)<>" "))ORDER BY [qrySelect
Distributors].SLSLNO;"
 
Not sure if there are any other errors but in the HAVING clause, you have 4
opening parentheses but only 3 closing parentheses.
 
Back
Top