Link to home
Start Free TrialLog in
Avatar of terpsichore
terpsichore

asked on

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?
User generated image
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

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
    docmd.quit

End Sub

Open in new window

Avatar of terpsichore
terpsichore

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks so much for these great insights.
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.