Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2013

    Unanswered: Access Filters- need help!


    I've exhausted my searching efforts and can't find a solution.

    List box name: lstOpCard
    Subform Name: frmPassdown
    MainForm: frmAF
    Filter Button name: testmultiselect

    I have a multi select list box and a subform on a main form. I would like someone to select the values in the list box, click a button, and filter the subform based on their selections.

    I currently have it where I click the button and it will store the selections in the list box in a string called "sTemp". The values in the string are numbers (associated with the key id). How can I then filter the subform based off of the string of numbers? The subform will also be filtered by a key id field. I would greatly appreciate any help!!

    Thank you,

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 15
    In the main form (frmAF) and provided that sTemp contains a comma separated list of values:
    Private Sub TestMultiSelect_Click()
        Dim sTemp As String
        Dim varItm As Variant
        For Each varItm In Me.lstOpCard.ItemsSelected
            If Len(sTemp) > 0 Then sTemp = sTemp & ", "
            sTemp = sTemp & Me.lstOpCard.Column(0, varItm)
        Next varItm
        If Len(sTemp) > 0 Then
            Me.frmPassdown.Form.Filter = "[name of key id field] IN ( " & sTemp & " )"
            Me.frmPassdown.Form.FilterOn = True
            Me.frmPassdown.Form.Filter = ""
            Me.frmPassdown.Form.FilterOn = False
        End If
    End Sub
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts