title: Access VBA simple sql select statement
body: <p>Coming from years of web development where PHP and SQL statements were so simple, this recent task I've been required to undergo with MS Access and VBA is absolutely doing my head in at how much it complicates SQL statements. Mind you I have no prior knowledge about VBA so it could be extremely simple and I'm not just getting it, but all I want to do is</p>
  
  <pre><code>"SELECT type FROM tblMatter WHERE id='$id'"
  </code></pre>
  
  <p>When I wear my PHP cap, I want to think okay, we are going to have one row of data, that's going to be an array, and I want one object out of that array. Simple.</p>
  
  <p>VBA, however, complicates the $#!t out of it. So far my code looks something like this</p>
  
  <pre><code>Dim matterSQL As String
  Dim matterRS As Recordset
  
  matterSQL = "SELECT type FROM tblMatter WHERE id'" &amp; id &amp; "'"
  Set matterRS = CurrentDb.OpenRecordset(matterSQL)
  
  MsgBox matterRS![type]
  </code></pre>
  
  <p><code>CurrentDb</code> is defined much much earlier in the code to open the connection to the database, and the error is on the line containing <code>OpenRecordset</code> with the error: <em>Data type mismatch in criteria expression</em>.<br>
  As I said, I'm new to VBA so I don't know what the heck I'm doing, and all the documentation on the internet is nowhere near helpful. But all I want to do is to get one piece of data from the table.</p>
  
  <p>Thanks in advance!</p>
  
  <hr>
  
  <p>Edit: I needed to build upon this with another query that takes the info from the last query to run. Same kind of ordeal:</p>
  
  <pre><code>Dim costSQL As String
  Dim costRS as Recordset
  
  costSQL = "SELECT email FROM tblScaleOfDisb WHERE category=" &amp; category
  Set costRS = CurrentDb.OpenRecordset(costSQL)
  
  MsgBox costRS![email]
  </code></pre>
  
  <p>This time I'm getting an error on the line containing <code>OpenRecordset</code> with the error: <em>Too few parameters. Expected 1.</em><br>
  Which I don't understand because the code is practically the same as the first half of the question. What have I done wrong?</p>