• Filter Subform using toggle button

    Author
    Topic
    #466125

    I’m just looking for an easy way to filter a subform (subform based on query) using a toggle. Something that is also easy to expand on since I can foresee multiple toggle buttons. Thanks.

    Viewing 1 reply thread
    Author
    Replies
    • #1206698

      On your toggle button — or, perhaps, from a dropdown combo selector — check the value of the toggle or the dropdown, and change the record source of your subform:

      Forms![YourParentForm]![YourSubformName].Form.RecordSource = “Select * from YourOriginalQuery where ToggleField = ” & YourJust-SelectedToggleValue
      …. and then re-query the subform’s recordsource: Forms![YourParentForm]![YourSubformName].Form.Requery

      If this isn’t what you’re looking for, why don’t you post a bit of your code.

      Pat

    • #1206708

      You can filter a form (or subform) either by changing its recordsource as Pat has suggested, or just by setting its “Filter” property to a string value, then setting the filterOn property to true.

      Code:
      Dim frm as form
      Set frm as me.subformcontrol.form
      frm.filter= "Surname like " & chr(34) & "A*" & chr(34)
      frm.filteron =true
      

      Chr(34) is just code for double quotes. Text values must be surrounded by double quotes.

    Viewing 1 reply thread
    Reply To: Filter Subform using toggle button

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: