title: Too few parameters. Expected 1 - but I have one
body: <p>So I've recently been working on a VBA script to transfer an entire database of student medical records from their old one-table, 68-field, flat system to a new dynamic system with 24 related tables.</p>
  
  <p>There was no issue for the first few tables, but then I ran into this. The line of code throwing the error is:</p>
  
  <pre><code>Set rstFrom = CurrentDb.OpenRecordset("select " &amp; Flat &amp; ".Student," &amp; Flat &amp; ".School," &amp; Flat &amp; ".Social," &amp; Flat &amp; ".FamilyHist from " &amp; Flat &amp; " WHERE 1=1")`
  </code></pre>
  
  <p><code>Flat</code> is a String which stores the name of the flat database (this is because I'm working with a dummy database so they will need a convenient and quick way to modify the code I make to work on the real thing)</p>
  
  <p><code>rstFrom</code> needs to contain only the columns of the 68-field table which are relevant to the table that I'm copying to at the moment (in this case, the FamilyHistory table which really just needs the <code>studentID</code> and <code>FamilyHistory</code>) - note that the original table did not assign unique <code>studentID</code>s, so I must use the name, school, and social to determine that I am dealing with the same child and look up their <code>studentID</code></p>
  
  <p>When this line of code runs I get the following error:</p>
  
  <pre><code>Run-time error '3061':
  
  Too few parameters. Expected 1.
  </code></pre>
  
  <p>Clearly I have 1 parameter, it's:</p>
  
  <p><code>"select " &amp; Flat &amp; ".Student," &amp; Flat &amp; ".School," &amp; Flat &amp; ".Social," &amp; Flat &amp; ".FamilyHist from " &amp; Flat &amp; " WHERE 1=1"</code></p>
  
  <p>(which after parsing is):</p>
  
  <p><code>"select Demos.Student,Demos.School,Demos.Social,Demos.FamilyHist from Demos WHERE 1=1"</code></p>
  
  <p>The where 1=1 is required when working with Access VBA or else it only returns the first record which matches, not all matching records.</p>
  
  <p>Has anyone else had this same problem as resolved it? I did notice one thing. When I change the parameter to:</p>
  
  <p><code>"select Demos.Student from Demos WHERE 1=1"</code></p>
  
  <p>It is able to get past this line no problem, although this causes issues later on when I need to read other data that I did not retrieve. I thought it was interesting, though, that the error seems to be coming from the SQL and not the OpenRecordset function.</p>