title: Access: How to execute a query and save its result in a report
body: <p>HI,</p>
  
  <p>I am trying to write a query in vba and to save its result in a report.
  I am a beginner. this is what i have tried 
  can somebody correct me</p>
  
  <pre><code>Dim cn As New ADODB.Connection, rs As New ADODB.Recordset
  Dim sql As String
  
  Set cn = CurrentProject.Connection
  sql = "Select * from table1 where empno is 0"
  
  rs.Open sql, cn
  
  
  While Not rs.EOF
  
  ' here i think i should save the result in a report but i am not sure how
  
    rs.MoveNext
  Wend
  rs.Close
  cn.Close
  Set rs = Nothing
  Set cn = Nothing
  </code></pre>
  
  <p>Also how do i change this query to run this on all tables in a database</p>