Preventing Form Closing In ACCDE

J

Jeff G

All -

Is there a way to prevent a user from being able to right click on a form
tab and selecting Close?

Or...how can I Undo or prevent a Record from being saved if they right click
and select Close?

Whem my form opens, there are some values placed in fields based on Null
values. I have events for Before Update and Close for data validation, but
if the form is closed via the right click option, a record gets written to
the db.

If I'm going about this the wrong way, some insight would be appreciated
too.

Thanks in advance.

Jeff
 
P

Paul Shapiro

Add an event handler for the form unload event, which will look like:
Form_Unload(Cancel As Integer). To prevent the form from closing, set Cancel
= True.
 
J

Jeff G

That work...the one problem though....

When I legitmately Close the Form (via Close Button), it cancels and won't
close the form.
 
P

Paul Shapiro

Have your close button set a module-wide variable or property named
something like fOKToClose to true, and then close the form. In the
Form_Unload event, check the value of that variable and allow the close if
it's true. Since it defaults to false, there isn't any way to close the form
except with your Close button.
 

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