query window - maximize then close quits application

Dear experts -
We open a form in our application - it invokes a query and displays the results in datasheet view.
The issue is that users are hitting the MAXIMIZE button in the upper right.
At this point, if the user hits the CLOSE BUTTON ('X') in the upper right (to close the form), this quits the application.
Below is an image of the setting for this form.
Any ideas?
image of form settings
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Developing Solutions LLCCommented:
I'm guessing that they are not hitting the forms "Close (x) button", but the applications "Close (x)" button.

I usually include a Splash form (the form that first loads when my application starts up) in my applications.  This form never gets closed until the use closes all other forms and returns to that application.  That form does has the standard Control Box and Close Button properties set to NO.

In that forms code module, I:

1.  declare a public variable in the form declarations section, which allows me to refer to this variable from throughout the form (and externally as well).

Public AllowClose as Boolean

2.  In the Form_Open event of this form, I set that value to False

    AllowClose = False

3.  In the Form_Unload event, I check to see whether that value is False, and if so, instruct the user to click the "'Quit" button.  This will prevent the form, and therefore the application from quiting, because the application cannot quit if there is still a form open.

Private Sub Form_Unload(Cancel as integer)

    if AllowClose = False then
        Cancel = True
         msgbox "Click the 'Quit' button to exit this application"
         if me.visible = false then me.visible = true 
    End IF

End Sub

Open in new window

4.  This form also contains a 'Quit' command button with code like:

Private sub cmd_Quit_Click

    AllowClose = True

End Sub

Open in new window

terpsichoreAuthor Commented:
I guess this is my problem - how do you 'find' the right close button? How to you 'refind' the controls for that form in datasheet mode?
Is there a simpler solution, where I can alter some of the form's settings?
Dale FyeOwner, Developing Solutions LLCCommented:
The problem is generally that there is no way to actually disable the Access close button in the upper right corner of the Access application.  When you have a form open, maximized, you will normally see more than one "Close" button (see image).
application and form close buttons
I know of no other way to prevent a user from closing an Access application other than the method described above.  I frequently extend this method to other forms (not just my Splash form) when I want to prevent users from closing a form except with a specified 'Cancel' or 'Save' button.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
terpsichoreAuthor Commented:
thanks so much for these great insights.
terpsichoreAuthor Commented:
Actually, I found another solution -
First, the calling form was NOT set to modal - this might have had something to do with it. I changed that to Modal.
For this form: a) I removed the 'can minimize' option; b) I turned BOTH 'popup' AND 'modal' to TRUE; and c) I left 'close box' TRUE as well.
This seems to have fixed the problem - I can now maximize the form (seen in datasheet view), and when I hit the close button, this form closes, NOT the application.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.