Results 1 to 8 of 8
  1. #1
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291

    How do I remove a filter

    I set the filter with the following:


    DoCmd.ApplyFilter , "[Area] = '" & Forms("IForm").cmbArea.Value & "'"

    Now the combo box has an option "All" where I need to remove the filter. How do I remove the filter?

    I tried:
    1 - DoCmd.ApplyFilter , "[Area] = '*'"
    2 - Forms("IForm").filter = ""

    and several other things. I would imagine this to be a simple fix, thanks for help.

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    How bout instead of applying the filter, then removing it if its all, creating an If statement that will only apply the filter if its not "all"?

  3. #3
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    If Forms("IForm").cmbArea <> "All" Then
    DoCmd.ApplyFilter , "[Area] = '" & Forms("IForm").cmbArea.Value & "'"
    End If

    ok so the person comes into the form and the combo box is defaulted to "All" then is switched to the second value which would be "Area 1" which will input the following code:
    DoCmd.ApplyFilter , "[Area] = '" & Forms("IForm").cmbArea.Value & "'" Which will produce
    DoCmd.ApplyFilter , "[Area] = 'Area 1'"
    At this point they move the combo box back to "All" and it doesnt remove the filter even with the shown if statement.

  4. #4
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    First off, I'm not a fan of default values. From personal experience, I've noticed it promotes user laziness. I'd force the user to pick one. Then run that if statement from a command button. I dont know off the top of my head how to undo a filter, unless you make a redundant query as the failsafe to recreate your original dataset.

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Try this shot-in-the-dark:

    Code:
    If Forms("IForm").cmbArea <> "All" Then
      DoCmd.ApplyFilter , "[Area] = '" &  Forms("IForm").cmbArea.Value & "'"
    Else
      Me.FilterOn = False
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    cosign on that idea pbaldy.
    more on that here.
    http://www.access-programmers.co.uk/...d.php?t=170924

  7. #7
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Me.FilterOn=False

    Or

    Try this

    Me.Filter=""

    the second one works too.

  8. #8
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    Nice got this one working, now I need help on why in the world this other question isnt working
    https://www.accessforums.net/forms/f...king-5378.html

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

Similar Threads

  1. remove a password
    By ngeng4 in forum Security
    Replies: 1
    Last Post: 03-30-2010, 05:52 AM
  2. Replies: 4
    Last Post: 02-01-2010, 05:21 AM
  3. How to remove duplicates
    By TonyBender in forum Access
    Replies: 0
    Last Post: 10-21-2009, 10:27 PM
  4. Remove Filter and GoToRecord
    By ombadboy in forum Programming
    Replies: 0
    Last Post: 09-04-2009, 07:35 AM
  5. Remove contents from each field
    By nancyszn in forum Access
    Replies: 7
    Last Post: 08-06-2009, 03:41 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