Results 1 to 4 of 4
  1. #1
    virgilio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    81

    Filtering Subforms

    Hi, I'm new to Access.

    I'm trying to filter a subform based on a toggle switch in the parent form.

    This subform is already updating the way I want with the values from a combo box in the parent form, but I want to further filter the results with a radio button, preferably in the parent form and I can't figure out how its done.



    My subform is using the following SQL for the 'Record Source' field:
    SELECT [Query1].[Reference_Number], [Query1].[Attribute_1], [Query1].[Binary_Status] FROM Query1;

    Refence_Number is used in the parent combo box to select the appropriate record.
    I want to use Binary_Status to filter 'True' values.

    When I right click the subform and use the text filter options available the subform does exactly what I want. Is there a way to export the text filter rules to use in a toggle switch? Is there a better way to filter this data?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    You can use VBA to set subform's Filter and FilterOn properties.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    virgilio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    81
    Hey, thanks for responding, I tried that but when I do so it ignores my combo box and sorts to the first true boolean it finds with my toggle switch.

    So I tried concatenating my filter string to include the combo box value, and the form crashes. This is my VBA for that toggle switch:

    Code:
    Private Sub Option40_AfterUpdate()
        Me.Filter = "Binary_Status = 'ON'" & " AND Reference_Num=" & Me.Reference_Num.Value
        Me.FilterOn = True
        
    End Sub
    Am I barking up the wrong tree, is there a better way to do this?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Code is in subform and Reference_Num is on main form? Binary_Status is a yes/no field?

    Me.Filter = "Binary_Status = True AND Reference_Num=" & Me.Parent.Reference_Num.Value

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 02-02-2015, 07:47 PM
  2. Subforms Inside Subforms
    By LordPanzer in forum Access
    Replies: 1
    Last Post: 10-11-2013, 05:19 PM
  3. Replies: 2
    Last Post: 01-02-2013, 02:43 PM
  4. Subforms Splitting and filtering
    By gg80 in forum Forms
    Replies: 3
    Last Post: 05-08-2012, 06:20 PM
  5. Problem linking subforms, filtering and uploading
    By sameerk0286 in forum Access
    Replies: 1
    Last Post: 12-09-2010, 09:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums