title: How to export access query result to excel?
body: <p>In a form I create a button (Export to excel).</p>
  
  <p>The code vba :</p>
  
  <pre><code>Private Sub Commande97_Click()
      Dim db As DAO.Database
      Dim req As DAO.QueryDef
  
      Set db = CuurentDb
      Set req = db.QueryDefs("R_BC_infos")
  
      req.SQL = SQLListBC
  
      Set req = Nothing
      Set db = Nothing
  
      DoCmd.OutputTo acOutputQuery, "R_BC_infos", "ExcelWorkbook(*.xlsx)", "", True, "", acExportQualityPrint
  End Sub
  </code></pre>
  
  <p>However when I click on the button its gives me error Object requis. </p>