Avatar of PerksP
PerksP
 asked on

Filtered form prompts to save on close

We have a database which uses the navigation subform tabs in MS Access 2010.  The front screen is a search facility where the user can search for an employee name and it will filter out the correct person.

However, when they click on another tab to open a different navigation subform this filtered form prompts to save the changes.  I have searched for ways to prevent this and tried removing the filter on unload, lost focus and close but those actions take place before the filter removes so it isn't doing the job.

The only solutions I have found require a close button which isn't appropriate where the user is in the Navigation Subforms as they just click from tab to tab.

Does anyone have any idea how I can prevent the save prompt.  I'd be most grateful!

Thank you in  advance
Microsoft Access

Avatar of undefined
Last Comment
PerksP

8/22/2022 - Mon
Gustav Brock

You can try to run this command, for example when you open the form:

    DoCmd.SetWarnings False

However, it is global, so you may wish to turn it on again, say, when closing the form:

    DoCmd.SetWarnings True

/gustav
PerksP

ASKER
Thanks for you quick replay Gustav

I just tried that but unfortunately it doesn't seem to apply to the save command which is still coming up when I switch to a different navigation tab
PatHartman

You are getting the save prompt because you have modified a form property.  I recommend that you change your process to not modify the form properties since that prevents you from distributing as an .accde or from using the Access runtime engine.

To get past the save prompt, close the form this way:

DoCmd.Close acForm, Me, acSaveNo
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
PerksP

ASKER
Thanks Pat

Unfortunately I can't use a button with code as they are using the Navigation Forms available in MS Access 2010.  This means that they switch between forms by clicking the tab rather than by clicking a close button
PatHartman

Then the best option is to stop modifying form properties.  What are you doing to change the form?
PerksP

ASKER
I have a field where they select an employee and it filters the dataset to show just that employee.  They then double click to go to the full record.

If they click away from this form to a different navigation form that is when they get the save prompt as it closes the form.

It is that which is causing the save prompt although I have used these fields in mdb files and never had a problem with a save prompt coming up.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gustav Brock

Perhaps you can use the OnChange event (changing tabs) of the form and run this:

DoCmd.Save acForm, Me.Name

But I would consider a different method for filtering and navigating.

/gustav
PatHartman

Personally, I don't use filters since they require loading the entire recordset and since I use mostly SQL Server, I really only want to retrieve the minimum set of records.  Therefore, I use criteria in the query to "filter" the form.  The criteria points to the controls where the selections are made.  Then I requery the form/subform.

Where somefield = Forms!yourform!somefield
PerksP

ASKER
I do use queries to filter a form but this was supposed to be easier to let them choose to filter by different fields each time e.g. surname, job title, department and also to easily remove the filter to show all records again.

Thanks for you help and advice.  I think I am going to have to think again as this is an unforeseen disadvantage to the navigation tabs.
Your help has saved me hundreds of hours of internet surfing.
fblack61
PatHartman

Access has always had problems filtering subforms and the navigation form puts your "main" forms on the navigation form so they become subforms.
ASKER CERTIFIED SOLUTION
PerksP

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Gustav Brock

One workaround is to forcely save the form before closing and/or to call

   DoCmd.SetWarnings False

when opening the form.
Then, when loading, reset by code the form to the default settings.

I once built a system for this for a client. It was a major task as he wanted the option for the user to save the current setting (filtering, freezing, columnwidths etc. etc.) without losing the option to reset to the default values. Of course, each user ran their own frontend, but all the settings were persisted in the backend to allow for updates of the frontend. The default values were persisted too, so the developers could work with the forms and save them without bothering for the default appearance; this was maintained by an application administrator.
As if this wasn't enough, the system automatically recorded new (and deleted) forms and fields and their formats.

So "There isn't a solution" is not quite right but it may be beyond the resources you wish to allocate.

/gustav
PerksP

ASKER
There isn't a solution.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.