title: create adodb RecordSet with query
body: <p>I would like to get a recordset in excel VBA by triggering a query stored in MsAccess.</p>
  
  <p>The code works fine when I add a proper SQL query, but I would like to avoid to add the query to the code, I would like to use a query stored in MSACCESS.</p>
  
  <pre><code>sql = "select * from qryUploadData"
  With RS
          .ActiveConnection = conn
          .CursorType = adOpenStatic
          .LockType = adLockOptimistic
          .Open sql
  End With
  </code></pre>
  
  <p>qryUploadData is the the name of the access query. If I put it into an SQL query as if it would be a table, it works fine, but it doesn't, if I try to open it directly. Is there any way to use it ? </p>