Results 1 to 5 of 5
  1. #1
    chungy50 is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Jan 2018
    Posts
    1

    Lightbulb Apply filter on existing filter from command buttons

    Hi there, I currently have a navigation form which houses an subform that has a set command buttons relating to the organisations different business units. Once you press on one of the buttons, the datasheet within this subform filters to that particular SBU.

    I want to have a secondary set of buttons related to the months, but i want the original filter of business unit to still be intact. i.e I want to first click on the business unit to filter that part of the business, and then i want to click on the particular month of interest to further filter out the business unit's performance at that particular month.



    So far, i have been able to filter both business units and month via browseto macros but i have only been able to do them independently.

    I would provide screenshots but unfortunately there is issues with IP... but thank you in advance!!

    Any help is great help.

    Regards,
    Steven

  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,930
    What code are you using? Review: http://allenbrowne.com/ser-62.html
    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
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    The way I manage multiple filters is to build the query SQL up in sections using strings, checking each part works then adding the next

    The overall SQL might be:
    Code:
    strSQL = strSelect & strFrom & strWhere & strGroupBy & strOrderBy
    It should hopefully be obvious what each part of the SQL string refers to.

    The filter part in strWhere might itself be made up of several parts
    Code:
    strWhere = " WHERE (" & strDateFilter & strIncidentTypeFilter & strYearFilter & strLocationFilter & strTimeFilter & ")"
    Individual filters would be like this:
    Code:
    strDateFilter = "([Incident Date] Between #" & Format(Me.txtFrom, "mm/dd/yyyy") & _
                "# And #" & Format(Me.txtTo, "mm/dd/yyyy") & "#) "
    
    strIncidentTypeFilter = " And [Incident Type] = '" & Me.cboIncidentType.Column(1) & "'"
    
    strLocationFilter = " And Location = '" & Me.cboLocation.Column(1) & "'"
    etc...

    So in the example below these combine to give
    Code:
    strWhere = " WHERE (([Incident Date] Between #01/21/2016# And #01/08/2018#)  And [Incident Type] = 'TAWG' And Location = 'Cockfosters')"
    In this case the output is a chart but the idea applies equally to a list of filtered records

    Click image for larger version. 

Name:	MultiFilter.PNG 
Views:	25 
Size:	24.5 KB 
ID:	32003

    Hope that helps rather than confuses you ...
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    One option is to limit the records returned from a query using the WHERE clause.
    The other option is to create a query that returns records limited by the WHERE clause, then use the form filter property to restrict which records are displayed.
    See http://www.allenbrowne.com/ser-28.html

    With the filter method, you can add more options to the filter or remove the filter and display all of the records.
    See http://www.allenbrowne.com/ser-62code.html

    I use the filter property method..

  5. #5
    deepakg27 is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    160
    thanks great post

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

Similar Threads

  1. Replies: 22
    Last Post: 09-08-2015, 04:43 PM
  2. Filter By Form and Apply Filter Buttons
    By JustLearning in forum Forms
    Replies: 13
    Last Post: 02-18-2015, 01:01 PM
  3. Replies: 2
    Last Post: 02-25-2013, 10:47 AM
  4. How to filter dates using an apply filter code.
    By Jgreenfield in forum Reports
    Replies: 4
    Last Post: 11-15-2011, 01:38 PM
  5. Apply filter command
    By miziri in forum Forms
    Replies: 6
    Last Post: 01-21-2010, 02:22 AM

Tags for this Thread

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