title: Microsoft Access Form with multiselect listbox
body: <p>I have a form in Microsoft Access which has a combobox which contains counties. Based on the selection of county there is a listbox which will show the amounts that are realted to that county. When I select a amount from listbox and click on find button then it will generate two subforms, one subform shows the lowest prices for line items present in that amount with query:</p>
  <pre><code>SELECT Data.Item, Min(Data.[Unit Price]) AS Minimum
  FROM Data
  WHERE (((Data.[Bid Amount])=Forms![Report]![List2]))
  GROUP BY Data.Item;
  </code></pre>
  <p>and the other subform shows the average prices for line items presnt in that amount  with query:</p>
  <pre><code>SELECT Data.Item, Avg(Data.[Unit Price]) AS Average
  FROM Data
  WHERE (((Data.[Bid Amount])=[Forms]![Report]![List2]))
  GROUP BY Data.Item;
  </code></pre>
  <p>Right now selecting a single amount from list box works fine but if I need to multi select the amounts from listbox then what code I need to write in Find button? I tried using code below but it is not working.</p>
  <pre><code>Dim varItem As Variant
  Dim strFind As String
  Dim Task As String
  
  For Each varItem In Me!List2.itemselected
      strFind = srtFind &amp; &quot;,&quot; &amp; Me!List2.ItemData(varItem)
  Next varItem
  If Len(strFind) = 0 Then
      Task = &quot;Select Amount(s)&quot;
  Else
      strFind = Right(strFind, Len(strFind) - 1)
      Task = &quot;select * from Data where ([Bid Amount] in (&quot; &amp; strFind &amp; &quot;))&quot;
  End If
  DoCmd.ApplyFilter Task
  </code></pre>
  <p>Also, I am attaching a screenshot of my form if it helps.
  <a href="https://i.stack.imgur.com/SO9Zs.png" rel="nofollow noreferrer">Access Form</a></p>