Results 1 to 5 of 5
  1. #1
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451

    DoCmd.applyfilter for multiple

    i am trying to learn as i go so all help and comments are welcome. i have a form that i would like to filter using the applyfilter. when i use it for only the "proceed is null" it works but when i try and add a second criteria to it for a yes/no field i'm bombing out. i tried
    DoCmd.applyfilter,"proceed is null" and "done is false"
    but that didn't work, also tried two seperate lines of command
    DoCmd.applyfilter,"proceed is null"


    DoCmd.applyfilter,"done is false"
    didn't work either, what is the proper way to filter for a text and a yes/no value?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    DoCmd.ApplyFilter , "proceed is null AND done = false"
    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
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by vicsaccess View Post
    ...what is the proper way to filter for a text and a yes/no value?
    I am not sure what criteria you want to apply but to answer your question ....

    If you have a Yes/No field you can create the following statement.
    [MyField] = -1

    And you can place it in a string like this.
    dim strFilter as string
    strFilter = "[MyField] = -1"

    A statement for a text value would look like
    [MyTextField] = 'Some Text'

    And you can place it in a string like this.
    strFilter = "[MyTextField] = 'Some Text'"

    You can add multiple criteria together
    strFilter = "[MyTextField] = 'Some Text' AND [MyField] = -1"


    I prefer to use the Filter property directly.

    Me.Filter = ""
    Me.FilterOn = false
    Me.Filter = strFilter
    Me.FilterOn = True

  4. #4
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    thanks guys, june7 that worked. whats the reason significance of the "AND" being capitalized? I tried that in lower case but it would not work.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    What I provided has the AND inside the quote marks because it is literal text. It is not an operator understood by VBA. Upper or lower case doesn't matter. I just like SQL key words to stand out.
    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. doCmd.OpenReport - Multiple Where Conditions
    By jml9012 in forum Programming
    Replies: 10
    Last Post: 05-20-2013, 08:45 PM
  2. Replies: 7
    Last Post: 02-26-2013, 02:26 PM
  3. Replies: 2
    Last Post: 09-29-2011, 10:57 AM
  4. DoCmd.ApplyFilter with wild card
    By cksm4 in forum Programming
    Replies: 3
    Last Post: 10-05-2010, 08:24 AM
  5. Help with ApplyFilter
    By kabichan in forum Programming
    Replies: 1
    Last Post: 01-15-2010, 09:21 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