Results 1 to 4 of 4
  1. #1
    Varda is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    44

    Filtering a Form by three different checkbox fields

    MS Access 2010



    I have a form with three fields that are of the Yes/No type (checkbox).

    I'd like to create a command button that would filter the form by which checkbox is Yes.

    At the same time I'd also like to allow the user to filter by another field (for Status).

    The code I have for applying the filter of status on the form is:

    Code:
       
        Dim strStatus As String
        Dim strFilter As String
    
     Select Case Me.fraStatus.Value
          Case 1
              strStatus = "='Active'"
          Case 2
              strStatus = "='On Hold'"
          Case 3
              strStatus = "='Closed'"
      End Select
    
    strFilter = "[Status]" & strStatus
    
    With Forms!MainForm
            .Filter = strFilter
            .FilterOn = True
    End With
    How do I add the criteria of a checkbox to this code?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Looking at your db. I see the checkboxes are bound. Controls for input of filter criteria must be unbound, like you have for Status and ReportType on right side of form.

    Should user be able to select only one of the 3 for filter criteria?
    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
    Varda is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    44
    The three checkboxes that are bound are data entry fields (they're located at the bottom half of the page). The controls I'm using for filtering are on the right side of the screen, below the the Status and Report Type filter option.

    User should select only 1 of the checkboxes for filter criteria. But I'm also interested how I'd do it if i allowed for 2 checkboxes?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Still need some unbound controls for input of filter criteria.

    How do you want the yes/no fields handled? If you use unbound checkbox for filter criteria, what do you want to happen when checked or unchecked? If checked select records where field is true, if unchecked select records where field is false? An unbound checkbox can be set with triple state enabled.

    Filtering on multiple yes/no fields along with other type fields can be confusing. Should you use AND or OR operators? Mixing AND and OR operators is particularly tricky - parens are critical. Picture the resulting statement and follow the logic. Will you get the desired output?
    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: 1
    Last Post: 11-26-2014, 02:30 PM
  2. Checkbox to Hide Fields not working
    By KerryAustin in forum Forms
    Replies: 2
    Last Post: 08-29-2014, 08:25 AM
  3. Replies: 2
    Last Post: 07-26-2014, 12:05 PM
  4. Multiple checkbox filtering & Clearing
    By Havvix in forum Access
    Replies: 3
    Last Post: 12-05-2012, 04:42 PM
  5. Report Fields Visible Based on Checkbox
    By ghillie30 in forum Access
    Replies: 2
    Last Post: 09-21-2011, 09:04 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