title: Filter form based on unbound control value
body: <p>I have a form bound to a query, except for one field that I am leaving unbound. The idea is that the user will enter a value in that textbox and press a button to bring up the record. I have some code that I thought would work based on the interwebs. When I use <code>DoCmd.ApplyFilter(filter_string)</code> I get a popup asking for the value to filter on (which is not what I want). When I go ahead and paste it in, the form does not get filled. When I use <code>Me.Form.Filter = filter_string</code>, sometimes the form fills, but always with the same record, regardless of what the <code>filter_string</code> says. An example <code>filter_string</code> is </p>
  
  <pre><code>filter_string = "InventoryDetailsID = 'B01MFC000100/01'"
  </code></pre>
  
  <p>I have another similar form that, instead of filling with an existing query, generates the query (with 5 joins) and fills the form from the resulting recordset. It works just fine, but is slow because it has to run the query each time. That is why I want to use a method where I generate the query once, and then filter it.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Oh, and I also tried using a variant on the run-the-query-every-time approach, where I query the already generated query (the one I'm trying to filter). I'm using:</p>
  
  <pre><code>query_string = "SELECT * FROM qry_ISBN_All WHERE InventoryDetailsID LIKE '" &amp; Me.InventoryDetailsID &amp; "';"
  </code></pre>
  
  <p>But I get the error <code>Run-time error '3061' Too few parameters, expected 1</code></p>
  
  <p><strong>Edit II</strong></p>
  
  <pre><code>Private Sub btn_Seek_Click()
      Dim temp As String
      filter_string = "InventoryDetailsID = '" &amp; Me.InventoryDetailsID &amp; "'"
      Me.temp = filter_string
      Me.FilterOn = True
      Me.Form.Filter = filter_string
      Me.FilterOn = True
      'DoCmd.ApplyFilter (filter_string)
  '    Dim query_string As String
  '    query_string = "SELECT * FROM qry_ISBN_All WHERE InventoryDetailsID LIKE '" &amp; Me.InventoryDetailsID &amp; "';"
  
  End Sub
  </code></pre>
  
  <p>Typical filter string is given. It is printed to the form control <code>Me.temp</code>.</p>