title: Using a VBA variable in SELECT Sql statement
body: <p>Is their a way to use a declared VBA variable in a SELECT Sql statement as follows (I have a table called <code>myTable</code> and i want to set the referenced field by passing the declared string <code>myVar</code>) :
  e.g passVar("English")</p>
  
  <p>NB: Am using Microsoft Access</p>
  
  <pre><code>Private Function passVar(myVar as string)
  
  Dim db As Database
  Dim qdf As DAO.QueryDef
  Dim stmnt As String
  
  Set db = CurrentDb()
  Set qdf = db.QueryDefs("SelectSubjectQuery")
  
  stmnt = "SELECT [myTable].[myVar] = " &amp;Chr$(34) &amp; myVar &amp; Chr$(34) &amp; _
  
           //other SQL statements go here
  
  qdf.SQL = stmnt
  
  End Function
  </code></pre>
  
  <p>Each time i run the query a dialog box appears asking for the value of <code>mytable.myvar</code> instead of passing <code>myvar</code> i.e Eglish as the referenced field on <code>myTable</code>.</p>