title: Using form combo boxes apply a filter to a query
body: <p>I think I am close to this one, but can't work out the filtering process.</p>
  
  <pre><code>tblIndex(PrimaryCat,SubCat,UserID,Year)
  tblResults(SubCat,UserID)
  </code></pre>
  
  <p>My Form has two combo boxes and a button. ComboBox1 has tblIndex.PrimaryCat values and ComboBox2 has tblIndexYear values.</p>
  
  <p>What I want is when the command button in the form is pressed, tblResults opens showing the list of SubCat and UserID values when the combobox values are used as a filter on tblIndex.</p>
  
  <p>Does this make sense?</p>
  
  <p>I have the recordsource of the form set to tblResults. I'm using this, just need to add in filtering somehow:</p>
  
  <pre><code>Private Sub cmdGo_Click()
  
  Dim strSQL As String
  
  strSQL = "SELECT SubCat, UserID " &amp; _
           "FROM tblIndex " &amp; _
           "WHERE PrimaryCat = [strCat] AND Year = [strYear] " &amp; _
           "GROUP BY SubCat, UserID"
  
  DoCmd.OpenQuery "strSQL"
  
  End Sub
  </code></pre>
  
  <blockquote>
    <p>EDIT:</p>
    
    <p>I'm not sure if I am allowed to answer my own question but I worked out a solution. I >used INTO to put the results into a temp table I can further manipulate using:</p>
    
    <p>Private Sub cmdGo_Click()</p>
    
    <p>Dim strSQL As String</p>
    
    <p>strSQL = "SELECT SubCat, UserID INTO tblTemp " &amp; _
                "FROM tblIndex  " &amp; _
                "WHERE PrimaryCat = '" &amp; cboPrimaryCat.Value &amp; "' AND Year = '" &amp; >cboYear.Value &amp; _
                "' GROUP BY SubCat, UserID"</p>
    
    <p>DoCmd.RunSQL strSQL</p>
    
    <p>End Sub</p>
  </blockquote>