title: Access VBA: Cannot combine variable and string in SQL query
body: <p>I have a list of users (as string variable) and want to use it as the criteria (one user at a time) for my SQL to pick the first item's code. So I put a SQL query as a string to run it later in the code. </p>
  
  <p>I've tried this:</p>
  
  <pre><code>strSQL = "SELECT TOP 1 Item.Code FROM Item WHERE Item.User = '" 
  strSQL = strSQL &amp; strUserName &amp; "' ORDER BY ID DESC"
  </code></pre>
  
  <p>If the strUserName = "A-user" for example, I only get this SQL string, according to "Quick Watch...":</p>
  
  <pre><code>SELECT TOP 1 Item.Code FROM Item WHERE Item.User = 'A-user
  </code></pre>
  
  <p>The part with <code>"' ORDER BY ID DESC"</code> isn't included in the SQL string at all!</p>
  
  <p>And for running the SQL query by using <code>"Set rst = CurrentDb.OpenRecordset(strSQL)"</code>, I get this error: </p>
  
  <blockquote>
    <p>Run-time error '3075':
    Syntax error (missing operator) in query expression 'Item.User = "A-user"</p>
  </blockquote>
  
  <p>How can I fix that?</p>