> Hello,
> Could anyone tell me how I can stop users from closing the access
> environment using the (x) at the top of the access screen.
> Robert
Hi Robert,
We added code to a form that we know will be open (our Main Menu) that
has code in the Unload event. When you cancel the Unload event of that
form, the database will not close.
Using this behavior, you could set a flag in a table or hidden control
that indicates whether the user is attempting to leave the database in
an approved way. If that flag isn't set, you can tell the user why they
can't exit that way.
A couple of extra notes:
We have found that canceling the unload event to prevent the database
from closing may clear all your Globals. But you really shouldn't use
Globals to store persistent values anyway.
There are ways to hide/disable the command buttons at the top of your
window. We don't use them, as that makes your app non-Windows standard.
Perhaps you should allow your users to use the X to exit, but use the
Unload code above to do any prompting or cleanup. That way they have a
standard Windows interface.

Signature
Armen Stein
Access 2003 VBA Programmer's Reference
http://www.amazon.com/exec/obidos/ASIN/0764559036/jstreettech-20
J Street Technology, Inc.
Armen _@_ JStreetTech _._ com
Brendan Reynolds - 03 Dec 2004 16:47 GMT
<snip>
> Perhaps you should allow your users to use the X to exit, but use the
> Unload code above to do any prompting or cleanup. That way they have a
> standard Windows interface.
That would be my recommendation. If you make it too difficult for users to
close an app, they'll start resorting to more drastic measures, ranging from
Alt+F4 through Ctrl+Alt+Del to reaching for the switch or even pulling the
plug.

Signature
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com
The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
Here is one from Steve Schapel
On the Load event of the form, set the Tag property to
something, for
example...
Me.Tag = "NoClose"
On the Unload event of the form, then something like...
If Me.Tag = "NoClose" Then
Cancel = True
MsgBox "Use the 'Exit' button on the form"
End If
And on the Click event of the button you want them to use...
Me.Tag = ""
DoCmd.close
Jim
>-----Original Message-----
>Hello,
[quoted text clipped - 3 lines]
>
>.
Jim/Chris - 03 Dec 2004 14:34 GMT
Sorry on the click event that you want to quit the
application should be this
Me.Tag = ""
DoCmd.exit
Jim
>-----Original Message-----
>Here is one from Steve Schapel
[quoted text clipped - 26 lines]
>>
>.