title: Creating a Search Form using a Combo Box in ms-Access
body: <p>Goal: I want to create a custom form to filter data from a table. I have a combo box which is used to select filter criteria and then generate a subform with the desired filtered data.</p>
  <p>Here is my code for populating the subform with the filter criteria only if a specific field matches my selected combo box value.</p>
  <pre><code>Private Sub comboBox_selection_AfterUpdate()
  Dim Filter_Function As String
  Filter_Function = &quot;SELECT * FROM mainTable WHERE ([Specific_Field] = &quot; &amp; Me.comboBox_selection &amp; &quot;)&quot;
  Me.Some_subform.Form.RecordSource = Filter_Function
  Me.Some_subform.Form.Requery
  End Sub
  </code></pre>
  <p>Results: When I select criteria from the combo box, I receive the message</p>
  <blockquote>
  <p>&quot;Syntax error (missing operator) in query expression
  '([Specific_field] = comboBox_selection)'&quot;</p>
  </blockquote>
  <p>When I try to debug the code, it highlights the line</p>
  <p><code>Me.Some_subform.Form.RecordSource = Filter_Function</code></p>
  <p>with a yellow arrow pointing to it.</p>
  <p>Additional Info:</p>
  <ol>
  <li>The table that is used to generate the combo box values comes from a different table &quot;Another_Table&quot;, not the mainTable</li>
  <li>The mainTable field that I am using as the field to check the matching combo box selection is also a combo box pulling options from the same &quot;Another_Table&quot;</li>
  </ol>
  <p>I am very new to VBA and coding in general, so I can tell that the error is probably something basic that I just have not learned yet. I triple checked all my spelling and punctuation, so I am quite confident that is not the issue (unless there is some weird rules saying I cannot capitalize my table/form names).</p>
  <p>I tried to find the answer on my own for the last couple of days, but failed.</p>
  <p>If someone could point me in the right direction, It would be much appreciated.</p>