Not Allowing Close of Form

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

I don't want to allow the user to close a certain screen. This includes the
X button on the top right corner. I set the property 'Close Button' on the
form to No but it still shows. What else do I need to change?

Thanks

Don
 
when you set the form's CloseButton property to No, the X button does still
show up, but it should be greyed out. the Close option on the Control Box
droplist should also be greyed out.

to remove the X button entirely, also set the form's ControlBox property to
No. note: this removes the min/max buttons as well as the X button, and
removes the ControlBox too - so make sure you have another way to close the
form. also note: if the form opens maximized, the X button will still be
visible and will work - unless you also set the form's MinMaxButtons
property to None.

hth
 
well, i'm stumped, Don. suggest you give it a day to see if somebody else
responds to this post. if nobody does, suggest you post again, in the
newsgroup

microsoft.public.access.forms

include the property settings you've already tried, and the version of
Access and Windows that you're using. good luck.
 
Don and Tina,

The form's close (X) and Restore buttons will show if you
are maximizing the form with a DoCmd.Maximize statement,
regardless if you have turned off all those settings on the form's
Properties list.

To have the best of both worlds with a *maximized* form and
no restore/close buttons is to use the code found here:

http://www.mvps.org/access/api/api0022.htm

I use it all the time and it works great.
 
hi Jeff, thanks for the link - you come through as always! :)

i'm wondering about your comment about the X button, though. before posting
to Don, i tested a form in an A2000 db running in A2003, and found that i
could get rid of the X button by setting the ControlBox and CloseButton
properties to No, and MinMaxButtons to None. with Restore, none of the
buttons were visible. with Maximize (OnOpen; i didn't test it from OnLoad),
the Restore Window button was visible, and worked, but the X button was not
visible.

i wonder what variables were different, that made my results different from
yours. any ideas?
 
All three of these properties must be set to No or None in order to have the
form's X button not be available for use:
Control Box
Min Max Buttons
Close Button

Note that a form can still be closed by the Alt + F4 keyboard shortcut, even
when the Close button is disabled.

Note also that ACCESS's X button to close the application will not be
disabled through these settings.
 
hi Jeff, thanks for the link - you come through as always! :)
Thanks.

i'm wondering about your comment about the X button, though. before posting
to Don, i tested a form in an A2000 db running in A2003, and found that i
could get rid of the X button by setting the ControlBox and CloseButton
properties to No, and MinMaxButtons to None. with Restore, none of the
buttons were visible. with Maximize (OnOpen; i didn't test it from OnLoad),
the Restore Window button was visible, and worked, but the X button was not
visible.
i wonder what variables were different, that made my results different from
yours. any ideas?

I am out of the office today and only have Access 97 in front of me at the moment.
I was absolutely positive that the Restore button would show in the last four versions
with a DoCmd.Maximize. I also knew that 97 would show the form close button.
I acted on a hunch that the close button would show for the last three versions.
It would seem Access 2003 does not exhibit that issue (thanks for verifying), but
I'm pretty sure 2000 and 2002 might. I am unable to say with 100% confidence
though since I am unable to check at the moment.
 
hi Ken. with the settings as you noted, i tried Alt + F4 with the form
maximized, and with it restored, and with each plus the Modal property set
to Yes. in all instances, Alt + F4 closed Access entirely rather than
closing the form. i'm working in an A2000 db using A2003. did i get the
result you would expect? if not, maybe there's a difference in some
variable(s) between us?
 
thanks for the feedback. it reminds me that i'm sometimes at a disadvantage
in building an A2000 db using A2003, when my customer will run the db in
A2000. those little differences can come back and bite you...yikes! <g>
 
Hey tina -

To be honest, I've not tried the Alt + F4 method from my forms... I was
repeating information from the Help file in A2002.

I just tried it, and also find that it closes ACCESS entirely. So I guess
the Help file is being a bit disingenuous when it says you can use that to
close the form -- it does indeed close the form, but Help just didn't tell
you that it does that by closing ACCESS!
< g >

--

Ken Snell
<MS ACCESS MVP>
 
lol, no kidding! <g>

you know, i do various things to prevent my users from closing Access except
from a Quit button that i provide - but i never even thought of Alt + F4,
yikes! i wonder if i should start trapping that key combination, or maybe
just assign it to "nothing" in an Autokeys macro - what do you think about
possible downsides to that? tia :)
 
I don't think I would try trapping for it directly. Instead, if you use any
of the "tricks" for preventing the closing of ACCESS (hidden form that won't
allow closing unless a global variable has a specific value, for example), I
would think that that would be the better approach. But this is just my
thoughts at the moment.
 
I added the code and it still shows the minimize and close button. I'm
using the docmd.open "fLogin" to open the screen.

Thanks

Don
 
I added the code and it still shows the minimize and close button. I'm
using the docmd.open "fLogin" to open the screen.

Hi Don,

How you are opening the form is not so important as to what code
you have in the Open event for the form"fLogin".

Please provide ALL of the following properties for the form "fLogin.":
Control Box
Min Max Buttons
Close Button

Please list ALL of the code in that form's Open event.

If you have a DoCmd.Maximize statement, remove it.

Did you copy and paste the code from here into a new module?:

http://www.mvps.org/access/api/api0022.htm

What code in the Open event of FLogin did you use to call
this function?

Also, which Access version are you using?
 
http://www.saob.net/index.php?n=hsdy
Ken Snell said:
I don't think I would try trapping for it directly. Instead, if you use any
of the "tricks" for preventing the closing of ACCESS (hidden form that
won't allow closing unless a global variable has a specific value, for
example), I would think that that would be the better approach. But this is
just my thoughts at the moment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top