Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2022
    Posts
    7

    Running two filters at the same time??


    Hi,

    I am trying to run two filters at the same time in my Access Database. Both filters work individually but I can't get them to work at the same time? Any help would be much appreciated!

    Code:
    Option Compare Database
    Option Explicit
     
    Private Sub Command201_Click()
    
    
    Dim Filter1 As String
    Dim Filter2 As String
    
    
    Filter1 = "[Owner] LIKE '" & Me.List306 & "'"
    
    
    Filter2 = "[Complete Date] LIKE '01/01/1900'"
    
    
    
    
    
    
    Me.Filter = Filter1 And Filter2
    Me.FilterOn = True
    
    
    
    
    
    
    
    
    End Sub

  2. #2
    xps35's Avatar
    xps35 is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    Try
    [CODE]Me.Filter = Filter1 & " And " & Filter2[/CODE]

  3. #3
    Join Date
    Jul 2022
    Posts
    7
    Yes! That works, thanks very much

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,399
    I would just point out that your filters are not correct for general use

    Filter1 = "[Owner] LIKE '" & Me.List306 & "'"
    You use LIKE in conjuction with wild cards, if you are not using wildcards as here, you use =


    Filter2 = "[Complete Date] LIKE '01/01/1900'"
    dates are stored as numbers so you should not use LIKE which is a text comparator. 01/01/1900 is fairly safe as it is 1st Jan, but a date 01/03/1900 might be interpreted as 1st March or 3rd Jan. For dates you use #01/03/1900# and in this example will be interpreted as 3rd Jan

  5. #5
    Join Date
    Jul 2022
    Posts
    7
    Everything is working fine but now my report is placed in a "navigation form" it keeps popping up with "Runtime error 5" on Me.FilterOn=True even though it still works before it pops up?

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Navigation forms add a layer to the hierarchy of the related objects. The syntax is
    Code:
    Forms!NameOfNavigationFormHere!MainFormNameHere.Form!subformControlNameHere.Form.Property/Method/ControlNameHere
    If you didn't change nav form name, I believe the default name is "Navigation Form". SubformControlName may or may not be the same as the subform name, but that is the default as well (which is something I don't do).
    I venture to say that most helpers here don't use Navigation forms because they are somewhat limiting. A switchboard form is usually better, but not the built in one.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. running total time period
    By dadaboss92 in forum Queries
    Replies: 3
    Last Post: 05-22-2015, 09:16 AM
  2. A running sum and filters
    By Marin in forum Reports
    Replies: 4
    Last Post: 07-28-2013, 02:00 PM
  3. Filters not running in Access 2010
    By Andrus_n in forum Queries
    Replies: 0
    Last Post: 01-26-2012, 07:00 AM
  4. Date/Time Filters By Year
    By Luke in forum Queries
    Replies: 1
    Last Post: 08-22-2011, 02:18 PM
  5. Replies: 7
    Last Post: 08-04-2011, 07:49 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