Results 1 to 6 of 6
  1. #1
    njliven1 is offline Novice
    Windows 10 Access 2007
    Join Date
    May 2022
    Posts
    7

    Using Option Group as a filter on a form.

    I need help setting up an option group to filer a list form on a yes/no field
    I want 3 options
    option 1 - No filter
    Option 2 - Filter to show all No


    Option 3 - Filter to show all Yes

    I set up the option group box with 3 buttons using the wizard, but there were no options to tell it what you wanted each button to do.

    I believe the code should be on the option box frame on the after update.
    I'm not real sure to go about writing the code for it though.

    Thanks in advance for any help!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You are correct that the code would go in the after update event of the frame. I'd use Select/Case testing the value of the frame. For each option, set the form's Filter and FilterOn values appropriately.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    njliven1 is offline Novice
    Windows 10 Access 2007
    Join Date
    May 2022
    Posts
    7
    So here is my code, but is is not working. No errors just clicking on the buttons does nothing. What am I doing wrong.

    Private Sub ViewInvoices_AfterUpdate()


    Select Case Me.ViewInvoices

    Case 1
    Me.FilterOn = False
    Case 2
    Me.FilterOn = [Paid] = "No"
    Case 3
    Me.FilterOn = [Paid] = "Yes"

    End Select



    End Sub

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No, each property gets set individually, and the filter argument is a string. More like:

    Case 2
    Me.Filter = "[Paid] = False"
    Me.FilterOn = True

    Note since the paid field is yes/no its value shouldn't be in quotes. You can use True/False, Yes/No, or -1/0.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    njliven1 is offline Novice
    Windows 10 Access 2007
    Join Date
    May 2022
    Posts
    7
    Thank you so much. It now works!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. I'm trying to filter by option group
    By Delta729 in forum Forms
    Replies: 8
    Last Post: 07-12-2021, 02:42 PM
  2. Option Group & Combo box Filter
    By nightfire22255 in forum Programming
    Replies: 1
    Last Post: 01-25-2021, 03:21 PM
  3. Replies: 3
    Last Post: 09-27-2018, 11:54 AM
  4. Replies: 2
    Last Post: 02-19-2013, 07:47 AM
  5. Use Option Group to Filter Combo Box Values
    By dgj32784 in forum Programming
    Replies: 2
    Last Post: 06-06-2011, 12:04 PM

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