Solved

Ms Access control an unintended close of the application

Posted on 2013-02-01
2
365 Views
Last Modified: 2013-02-01
I have a main form with a close button that has code that tests for the unintended exit of the app.  This works fine.  Any attempt to put similar code in the form unload event does not work.  Users sometimes mistakenly hit the close control on the main menu.  Is there a way to catch that and cancel the closing of MS Access?  Thanks
0
Comment
Question by:Sbovino
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
Guru Ji earned 250 total points
ID: 38844782
You can't cancel the close event but you can cancel the unload event, so you can put this in your unload event and it will prompt you when closing.


Private Sub Form_Unload(Cancel As Integer)

    If MsgBox("Test", vbYesNo + vbExclamation, "Confirm close") <> vbYes Then
         Cancel = True
    End If

End Sub
0
 

Author Closing Comment

by:Sbovino
ID: 38844815
Thanks, Worked perfectly!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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