Stop saving the filter entered by the user

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an application written in Access that is used to maintain our Oracle database. I have created a form that automically opens up in "filter by form" mode. After the user opens the form they enter the information they want to filter on, look at the results and then closes out of that form. It does not ask if you want to save changes, but when I then look at the properties for the form, the filter information the user entered is saved in the filter property.

Does anyone know a way of not saving the filter that was entered by the user??

Any help on this would be much appreciated by myself and my frustrated customers.

Thanks, Connie
 
1) When you close the Form, you can specify that it NOT save changes.
"DoCmd.Close acForm, MyFormName, acSaveNo"
acSaveNo only refers to saving changes to the Form and its properties (like
Filters), NOT to changes in the records/data displayed on the form.

and/or

2) In the Form_Unload event:
Me.Filter = ""
Me.FilterOn = False
This way, even if the Filter property does get saved, you are saving it in
an "off" condition.

--
George Nicholson

Remove 'Junk' from return address.




ConnieA said:
I have an application written in Access that is used to maintain our
Oracle database. I have created a form that automically opens up in "filter
by form" mode. After the user opens the form they enter the information
they want to filter on, look at the results and then closes out of that
form. It does not ask if you want to save changes, but when I then look at
the properties for the form, the filter information the user entered is
saved in the filter property.
 
I have an application written in Access that is used to maintain our Oracle database. I have created a form that automically opens up in "filter by form" mode. After the user opens the form they enter the information they want to filter on, look at the results and then closes out of that form. It does not ask if you want to save changes, but when I then look at the properties for the form, the filter information the user entered is saved in the filter property.

Does anyone know a way of not saving the filter that was entered by the user??

Any help on this would be much appreciated by myself and my frustrated customers.

Thanks, Connie

Connie, use the form's open event to deal with this - I also undo any
sorting this way.

Private Sub Form_Open(Cancel As Integer)
Me.OrderBy = ""
Me.Filter = ""
End Sub

That should be all you need.

- Jim
 
1) No, not the FormClose event. What causes the form to close now? There
should be something that is closing it now.
You probably already have something like
DoCmd.Close acForm, MyFormName
or
DoCmd.Close acForm, Me.Name

already. (maybe attached to a "Close Form" button?). You may only need to
add a comma and acSaveNo to that line.

2) Yes, replace MyFormName with the name of your form in quotes.
3) Yes, all one line

--
George Nicholson

Remove 'Junk' from return address.


ConnieA said:
Thank you for answering my question. I prefer option 1, but am unable to get this to work.

Please excuse my ignorance, but I'm very new to access.

I am assuming that I'm placing this code in the onClose event and I'm also
assuming that were MyFormName is I place my actual form name. Am I correct
on these assumptions? And do I just string this whole statement along one
line?
 
Connie, option 1 is not the best choice. It is really about saving
modifications to a form. I'm pretty sure it will throw an error in
production mode that would have to be dealt with. Option 2 is a better
choice, however you don't need to set FilterOn to false just set its
value to an empty string. (You can also do this in Open Form)

- Jim
 
Connie, dont worry about the filter property you see in design mode.
Code in the Open event will over-ride whatever is there. But, if you
want to get rid of it, just delete it in design mode and do a save.

- Jim
 
Connie in my first post I supplied the following code.

Private Sub Form_Open(Cancel As Integer)
Me.OrderBy = ""
Me.Filter = ""
End Sub

That's all you need!
Don't use the FilterOn property at all.

Try it.

(and I hope you are not allowing your users to open forms in design
mode)

- Jim
 
Good morning Jim...

I tried what you suggested and it worked!!! Yeah.... I guess if I had paid attention the first time, I would have gotten this working sooner.

Thank you for being patient with me :)))

Connie
 
Back
Top