Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Does that mean i can not have select query in my SP?</p> </blockquote> <p>No, the error message is telling you that Access thinks your query is a SELECT query (or some type of query that returns records) and you are trying to <code>.Execute</code> it. Access doesn't like that because it thinks you should be assigning the returned records to a <code>Recordset</code>.</p> <p>To create a pass-through query (PTQ) in DAO you must </p> <ul> <li>set the <code>.Connect</code> property of the QueryDef to at least <code>ODBC;</code>, and</li> <li>set the <code>.ReturnsRecords</code> property to <code>False</code> if it does not return a rowset</li> </ul> <p>Here is the bare-bones code to create a PTQ:</p> <pre><code>Sub CreatePTQ() Dim cdb As DAO.Database, qdf As DAO.QueryDef Set cdb = CurrentDb Set qdf = cdb.CreateQueryDef("ptq") qdf.Connect = "ODBC;" qdf.ReturnsRecords = False qdf.SQL = "EXEC foo" qdf.Close Set qdf = Nothing Set cdb = Nothing End Sub </code></pre> <p>Also, in your code you are replacing the placeholders with the <em>names</em> of the form controls, e.g., ...</p> <pre><code>strSQL = Replace(c_strSQL, "{P1}", "Forms!CopyVendor!CurCo") </code></pre> <p>...when you should be replacing those placeholders with the controls' <em>values</em>...</p> <pre><code>strSQL = Replace(c_strSQL, "{P1}", Forms!CopyVendor!CurCo) </code></pre> <p>...and remember that if any of the parameters are strings then you'll need to put quotes around them in the <code>EXEC</code> statement.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload