title: Parameter formatting in VBA prompting a 'Type mismatch' error at runtime?
body: <p>I'm adapting some inherited MS Access VBA code (below) so I realise there are better ways to manage this but, that said, what I've done should do the job.  I can can see that there should probably be a closing parenthesis at the end of this SQL string, so there is something amiss but I can't see it!  When I try to execute this line of code I get a 'Type mismatch' error on 'openrecordset', this leads me to believe there is something wrong in the way the query parameters are syntaxed, can anyone help (preferably with a tweak rather than a rewrite).  Many thanks in advance.</p>
  <pre><code>Set Owners = db.OpenRecordset(&quot;SELECT RES_LoginRef.UserID_USE_REF, 
  RES_LoginRef.ResSysID, RES_LoginRef.UserID, AGENTS.WIN_Username, 
  RES_LoginRef.EmploymentID, RES_LoginRef.RL_IncludeFrom, 
  RES_LoginRef.RL_IncludeTo
   FROM AGENTS INNER JOIN (RES_LoginRef INNER JOIN EMP_HISTORY ON 
  RES_LoginRef.EmploymentID = EMP_HISTORY.EmploymentID) ON AGENTS.AgentID = 
  EMP_HISTORY.AgentID WHERE (((RES_LoginRef.ResSysID)=1) AND 
  ((RES_LoginRef.RL_IncludeFrom&lt;=#&quot; &amp; Format([Forms]![Parameters]! 
  [ProcessDate], 
  &quot;mm/dd/yy&quot;)) &amp; &quot;# AND ((RES_LoginRef.RL_IncludeTo&gt;=#&quot; &amp; Format([Forms]!
  [Parameters]![ProcessDate], &quot;mm/dd/yy&quot;) &amp; &quot;# Or RES_LoginRef.RL_IncludeTo Is 
  Null);&quot;
  </code></pre>