2

I've an error on this code:

 Promo_var = Modifiable84.Value
   MsgBox Promo_var

   DoCmd.Hourglass True 'icone tablier a true

   ' set to break on all errors
   Application.SetOption "Error Trapping", 0

   ' start with a clean file built from the template file
   sTemplate = CurrentProject.Path & "\PlanificationAnnuelle_Template.xlsx"
   sOutput = CurrentProject.Path & "\PlanificationAnnuelle.xlsx"
   If Dir(sOutput) <> "" Then Kill sOutput
   FileCopy sTemplate, sOutput

   ' Create the Excel Applicaiton, Workbook and Worksheet and Database object
   Set appExcel = New Excel.Application
   Set wbk = appExcel.Workbooks.Open(sOutput)
   Set wks = appExcel.Worksheets(cTabTwo)

   sSQL = "SELECT Nom, PROMO, Semestre1A, Semestre1B, Semestre2A, Semestre2B, CatSemestre1A, CatSemestre1B, CatSemestre2A, CatSemestre2B FROM Planif WHERE CatSemestre1A > 0 OR CatSemestre1B > 0 OR CatSemestre2A > 0 OR CatSemestre2B > 0 WHERE PROMO = '" & Promo_var & "' ORDER BY Nom ASC "
   MsgBox sSQL
   Set dbs = CurrentDb
   Set rst = dbs.OpenRecordset(sSQL, dbOpenSnapshot)

The error occurs on these line:

Set rst = dbs.OpenRecordset(sSQL, dbOpenSnapshot)

The error is error

'3075' Syntax error (missing operator)

I can't find where is the problem. i've tried several sql change but i'm loose

1
  • 1
    So bad i've two WHERE ! i'm so break! Commented Nov 13, 2017 at 18:23

1 Answer 1

4

You call WHERE two times in your query

SELECT Nom, PROMO, Semestre1A, Semestre1B, Semestre2A, Semestre2B, CatSemestre1A, CatSemestre1B, CatSemestre2A, CatSemestre2B 
FROM Planif 
WHERE CatSemestre1A > 0 OR CatSemestre1B > 0 OR CatSemestre2A > 0 OR CatSemestre2B > 0 
WHERE PROMO = '" & Promo_var & "' 
ORDER BY Nom ASC 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.