title: Trying to populate a textbox with the result from sql/vba and getting #Name error
body: <p>I am trying to populate a textbox on an Access form with a value from a query where the selection criteria is another variable.
  The code is generating the sql, which I then put into the rowsource of the textbox object but I just get a #Name in the textbox. 
  The generated sql is working if I put it into the query builder and run it. </p>
  
  <pre><code>With Me.txtSupplier_ID
          .SetFocus
          .ControlSource = "(SELECT [Customer_ID] FROM [qrySelectCustData] WHERE [CustomerName] ='" &amp; cVal &amp; "')"
          .Requery
  
  End With
  </code></pre>
  
  <p>The generated sql is working if I put it into the query builder and run it. </p>
  
  <pre><code>With Me.txtSupplier_ID
          .SetFocus
          .ControlSource = "(SELECT [Customer_ID] FROM [qrySelectCustData] WHERE [CustomerName] ='" &amp; cVal &amp; "')"
          .Requery
  
  End With
  </code></pre>
  
  <p>The textbox should be populated with the customer id related to the customer name. The name is coming through fine and the controlsource is populated fine but still getting the #Name? error instead.</p>