How to prevent users to close access

M

Marco

Hi. I have on my switchboard form a commnd that asks to users if they realy
want to close the application.

But how can I do the same to the access it self?

If my users try to close the form a message box will appear. If I put the
same command to that form unload event it will asks if they really wan't to
leave, but if users press close button of access control buttons, the message
will ask if they want to quit the application but even if they say no the
application will close.

How can I prevent this?

Regards.

Merry christmas to all.

Cheers,
Marco
 
B

boblarson

Put a boolean flag in the declarations section of a standard module:
Public blnClose As Boolean

Then,

1. In your click event of your close button on the switchboard put blnClose
= True
2. in your Switchboard's Unload event check to see if the blnClose is true
and if not cancel the the unload:

If blnClose = False Then
Cancel = True
End If
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________
 
T

Tony Toews [MVP]

Marco said:
Hi. I have on my switchboard form a commnd that asks to users if they realy
want to close the application.

But how can I do the same to the access it self?

Why does it matter? If they accidentally click on the exit command
button then they just have to start it up again. A few wasted disk
IOs is the only problem.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
E

Erwin Vanhecke

It matters because some code is not run.

Ie: I'd like to log when the users start up my application and when they
close it. When they use the "Quit" button I've made, it fires a subroutine
that writes a record into a table and the it quits the application. If the
press the Access close button (the X in the right upper corner) this code is
not run, so it gives me the impression that there are still users working ;)
 
D

Douglas J. Steele

You said you had something in your switchboard that asked them before it was
closed. Presumably that means you've got code in the switchboard's Unload
event. That same code will prevent them from closing Access.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)
 
R

Rick Brandt

Erwin said:
It matters because some code is not run.

Ie: I'd like to log when the users start up my application and when
they close it. When they use the "Quit" button I've made, it fires a
subroutine that writes a record into a table and the it quits the
application. If the press the Access close button (the X in the right
upper corner) this code is not run, so it gives me the impression
that there are still users working ;)

Put your code in the close or unload event of a form that is always open or
a hidden one that you open at startup. Then it will run no matter how they
close Access (short of hitting the reset button on the PC).
 

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

Top