Clear Filter on closing a form

Discussion in 'Microsoft Access Form Coding' started by Guest, Jul 17, 2007.

  1. Guest

    Guest Guest

    Hello,

    Waht is the VBA for every closing the form, the filter will atuotomatically
    removed, because often that it will remember the filter and the clerck said "
    I can not see my data that I just entered" they he/she did not remove the
    filter.

    On the form property I would write the VBA on close event.

    Thanks in advance,

    Frank
     
    Guest, Jul 17, 2007
    #1
    1. Advertisements

  2. Try:

    Private Sub Form_Close()

    Me.FilterOn = False
    Me.Filter = vbNullString

    End Sub

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "Frank Situmorang" <> wrote in message
    news:...
    > Hello,
    >
    > Waht is the VBA for every closing the form, the filter will
    > atuotomatically
    > removed, because often that it will remember the filter and the clerck
    > said "
    > I can not see my data that I just entered" they he/she did not remove the
    > filter.
    >
    > On the form property I would write the VBA on close event.
    >
    > Thanks in advance,
    >
    > Frank
    >
     
    Douglas J. Steele, Jul 17, 2007
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Doug,
    I have put your code, but it does not work. I tried to open my form than I
    put cursor in the amount field, and typed >1000000, then I filter by form, it
    worked, it showed only amount bigger than 1 million, than I closed the form,
    and I open it again, and I see the one that I typed in the amount field
    >1000000 still showed.


    I appreciate your idea again.

    Thanks

    Frank


    "Douglas J. Steele" wrote:

    > Try:
    >
    > Private Sub Form_Close()
    >
    > Me.FilterOn = False
    > Me.Filter = vbNullString
    >
    > End Sub
    >
    > --
    > Doug Steele, Microsoft Access MVP
    > http://I.Am/DougSteele
    > (no e-mails, please!)
    >
    >
    > "Frank Situmorang" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > Waht is the VBA for every closing the form, the filter will
    > > atuotomatically
    > > removed, because often that it will remember the filter and the clerck
    > > said "
    > > I can not see my data that I just entered" they he/she did not remove the
    > > filter.
    > >
    > > On the form property I would write the VBA on close event.
    > >
    > > Thanks in advance,
    > >
    > > Frank
    > >

    >
    >
    >
     
    Guest, Jul 18, 2007
    #3
  4. You sure the code is actually firing? Put a breakpoint in there to make sure
    it is.

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no private e-mails, please)


    "Frank Situmorang" <> wrote in message
    news:...
    > Doug,
    > I have put your code, but it does not work. I tried to open my form than I
    > put cursor in the amount field, and typed >1000000, then I filter by form,
    > it
    > worked, it showed only amount bigger than 1 million, than I closed the
    > form,
    > and I open it again, and I see the one that I typed in the amount field
    >>1000000 still showed.

    >
    > I appreciate your idea again.
    >
    > Thanks
    >
    > Frank
    >
    >
    > "Douglas J. Steele" wrote:
    >
    >> Try:
    >>
    >> Private Sub Form_Close()
    >>
    >> Me.FilterOn = False
    >> Me.Filter = vbNullString
    >>
    >> End Sub
    >>
    >> --
    >> Doug Steele, Microsoft Access MVP
    >> http://I.Am/DougSteele
    >> (no e-mails, please!)
    >>
    >>
    >> "Frank Situmorang" <> wrote in message
    >> news:...
    >> > Hello,
    >> >
    >> > Waht is the VBA for every closing the form, the filter will
    >> > atuotomatically
    >> > removed, because often that it will remember the filter and the clerck
    >> > said "
    >> > I can not see my data that I just entered" they he/she did not remove
    >> > the
    >> > filter.
    >> >
    >> > On the form property I would write the VBA on close event.
    >> >
    >> > Thanks in advance,
    >> >
    >> > Frank
    >> >

    >>
    >>
    >>
     
    Douglas J. Steele, Jul 18, 2007
    #4
  5. Guest

    eljefegeneo

    Joined:
    Aug 4, 2012
    Likes Received:
    0
    I have the same problem. I tried the code suggested and it didn't work either.
    I have tried all sorts of code including:
    Private Sub cmdRemoveFilters_Click()
    If Me.Form.FilterOn Then
    Me.Form.Filter = ""
    Me.Form.FilterOn = False
    End If
    End Sub

    I can't get the filter to clear. If I click on the button with the above code, which will permit me to filter by form again without anything in the field which I had put the previous selection criteria, but when I close the form, open it again, the same field in which I had the original search criteria still contains the search criteria. The only thing that works it to first click on the button with the above code, then filter by form.
    But why won't it clear the filter on close (or open or load or whatever)?
     
    eljefegeneo, Aug 4, 2012
    #5
  6. Guest

    eljefegeneo

    Joined:
    Aug 4, 2012
    Likes Received:
    0
    I just fournd this. It seems to work. I say that will a little intrepedation but I tried ti several times and it seemed to clear the filter. It is not my code, and I don't take responsibilty for it.
    Private Sub Form_Open(Cancel As Integer)
    On Error GoTo Form_Open_Err

    Me.Filter = ""
    Me.FilterOn = False

    Form_Open_Exit:
    Exit Sub

    Form_Open_Err:
    MsgBox Err.Number & " - " & Err.Description
    Resume Form_Open_Exit

    End Sub
     
    eljefegeneo, Aug 4, 2012
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Douglas J. Steele

    Re: Removing Filter Criteria from the Form's Filter Property

    Douglas J. Steele, Mar 12, 2004, in forum: Microsoft Access Form Coding
    Replies:
    3
    Views:
    715
    Guest
    Mar 15, 2004
  2. Mota

    How to clear a filter in property sheet ?

    Mota, Aug 20, 2004, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    298
    Stewart Tanner
    Aug 23, 2004
  3. Matt via AccessMonster.com

    How to Clear acFormAdd Filter

    Matt via AccessMonster.com, Dec 21, 2005, in forum: Microsoft Access Form Coding
    Replies:
    3
    Views:
    1,707
    Allen Browne
    Dec 23, 2005
  4. Guest

    Filter Filter Filter

    Guest, Nov 27, 2006, in forum: Microsoft Access Form Coding
    Replies:
    5
    Views:
    731
    Guest
    Nov 28, 2006
  5. Russ via AccessMonster.com

    Trying to use the filter on the form to filter report

    Russ via AccessMonster.com, Dec 12, 2006, in forum: Microsoft Access Form Coding
    Replies:
    3
    Views:
    265
    Rick Brandt
    Dec 12, 2006
  6. Guest

    Remove Filter and Clear Data

    Guest, Dec 27, 2006, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    155
    Steve Schapel
    Dec 27, 2006
  7. Pat Dools

    Passing ID from Form A to Form B and closing Form A

    Pat Dools, Mar 28, 2009, in forum: Microsoft Access Form Coding
    Replies:
    8
    Views:
    414
    Tony Toews [MVP]
    Mar 31, 2009
  8. Replies:
    3
    Views:
    1,150
    Ron2006
    Jun 1, 2009
Loading...