[Last Call] Learn how to a build a cloud-first strategyRegister Now


Access 2007 - how to cancel the closing of the database?

Posted on 2011-04-27
Medium Priority
Last Modified: 2012-06-27
Hi Experts,

I'm trying to check for a condition when a form is deactivated. If the condition is true, I really want the user to get the message before they're done with their session. The "On deactivate" event for the form fires when the user attempts to close the database. Can I use the "On deactivate" code to stop the user from closing the database if the condition is true? How would I stop the database from closing?

Question by:JC_Lives
  • 2
LVL 75

Accepted Solution

DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 35480895
Use the Form Unload event, which can be cancelled:

Private Sub Form_Unload(Cancel As Integer)
    If <YourCondition> = True Then Cancel = True
End Sub


Author Closing Comment

ID: 35480919
Perfect, thank you.
LVL 75
ID: 35480929
You are welcome ...


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question