Closing Forms

tmyers

Well-known member
Local time
Today, 06:57
Joined
Sep 8, 2020
Messages
1,091
This is a best practice question.

Should there be a module that, when someone just closes the DB via say the X in the top corner, to handle all the forms closing and unloading? I have a couple users that love to just close the DB when they are done rather then backing out of it and closing it like I would expect a normal person to. Most of my forms open and close each other while setting focus back and forth so when this is done it causes a bunch of errors I have to try and manage so it doesn't just go haywire on the person.

I figured trying to outright disable the close button wouldn't be a good design (if it can be done) as I don't like overriding basic Windows functions.
 
If closing the app causes errors, then perhaps it's not about best practice but more of a necessity for you.
 
The "best practice" issue is "purity of purpose." If a form has a purpose, it rarely or never should depend on another form. The exceptions are, of course, sub-form cases, dispatcher forms, and switchboard forms, and the occasional pop-up. But two forms, neither of which are in my exceptions list, should never depend on each other. You get virtual spaghetti code with all those external cross-dependencies.

When you say that your forms open and close each other, you are introducing cross-form dependencies which can lead to a broken chain of dependencies when someone does something out of sequence. According to Murphy's Law, what CAN go wrong WILL go wrong. Murphy's Corollary is, make it so that it cannot go wrong in the first place.
 
I model a lot of my forms from Northwind where they have "hyperlinked" fields to click that open other forms. I have started using buttons/combos more and more however to handle navigation due to the problems I described in OP with my current methods.
 
If you are basing your forms on those in the older Northwind dating from A2007 or earlier, there are many issues that will cause problems
 
You could disable the Application Window Close button. There is code on this site to show how it is done with an API call.
 
You could disable the Application Window Close button. There is code on this site to show how it is done with an API call.
I had looked at that but I don't like disabling things that people generally expect to work as I think it makes things even more clunky in the long run.
If you are basing your forms on those in the older Northwind dating from A2007 or earlier, there are many issues that will cause problems
Should I not use the current Northwind as a reference point? I liked the layout of the forms for the most part and how the navigation was done. I have not used or, intentionally at least, replicated/used code from it.
 
I was deliberately referring to the old Northwind versions
The new Northwind 2.0 templates are MUCH better. Hopefully using those wouldn't cause any problems

Another possible approach is to hide the Access application interface completely.
You will no longer see the title bar or items such as the close button.
 
I believe the version I have is the old one. Now as to which version, I am not entirely sure. I do use code to hide the ribbon and such that I found from one of your post but I wont implement it until the DB is ready to distribute.

Out of the couple Access apps I have made (or butchered depending on view), this one I am hoping to actually post when it is decently functional for you all to critique and see how I did, which hopefully wont be terribly bad :)
 
I had looked at that but I don't like disabling things that people generally expect to work as I think it makes things even more clunky in the long run.
Some developers hide the Application window completely and just show the forms and reports. That way users don't actually realise anything is missing.
 
Some developers hide the Application window completely and just show the forms and reports. That way users don't actually realise anything is missing.
Ive used Isla's code for that as well. I haven't managed to get it to work without being really clunky though.
 
Ive used Isla's code for that as well. I haven't managed to get it to work without being really clunky though.
It can be more challenging to code where the interface is removed.
However if this is planned from the start it works well in my experience. Things get more problematic when you try to do this with a long established application which was never intended for that purpose.
 

Users who are viewing this thread

Back
Top Bottom