title: Access 2003 VBA: query works when run directly, but run-time error 3061 when run from code?
body: <p>So I have a relatively simple query that has exactly two parameters, one of which pulls a long from a form and selects only records from a single table, where one field has that value. (It's a table of design projects and the user is selecting a designer whose projects should be listed.)</p>
  
  <p>If I open the form and then manually open the query it works <em>perfectly</em>. If I have a second form (which populates a listbox with the query results) try to set a recordset equal to the query results, it fails with "Run-time error '3061'. Too few parameters. Expected 1."</p>
  
  <p>If I set the parameter to a static integer, e.g. 3, it works fine (but is clearly useless). Why would my VBA code be unable to read text from a text field on a form, when Access itself clearly can?</p>
  
  <p>Here is my query:  </p>
  
  <pre><code>SELECT [Project Request Log TABLE].Designer1, [Project Request Log TABLE].Priority, [Project Request Log TABLE].ProjectName, [Project Request Log TABLE].Manager, [Project Request Log TABLE].SME1, [Project Request Log TABLE].Priority, [Project Request Log TABLE].ProjectID
  FROM Designers INNER JOIN [Project Request Log TABLE] ON Designers.ID = [Project Request Log TABLE].Designer1
  WHERE ((([Project Request Log TABLE].Designer1)=[Forms]![frm_selectDesigner]![txtDesignerId]) AND (([Project Request Log TABLE].PercentComplete)&lt;&gt;1))
  ORDER BY [Project Request Log TABLE].Designer1, [Project Request Log TABLE].Priority;
  </code></pre>
  
  <p>Here is the line of VBA that gives the error:</p>
  
  <pre><code>  Set rst_projects = dbs.OpenRecordset("qryDesignerProjectPrioritySet", dbOpenDynaset)
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>Edit: the form on which one selects a designer opens the second form, on which the above code attempts to open a recordset. The original frm_selectDesigner is not closed, it is hidden when one clicks OK, but remains open.</p>
  
  <p>Edit 2: If I include the line  </p>
  
  <pre><code>DoCmd.OpenQuery "qryDesignerProjectPrioritySet"
  </code></pre>
  
  <p>The query opens and has the right results. If the very next line tries to assign the results of that query as a recordset as above, it gives the 3601 error? There must be some sort of error in how I wrote the OpenRecordset command, right?</p>