Solved

Inactivate Alt+F4 in Access (the x Button)

Posted on 2006-07-19
2
361 Views
Last Modified: 2006-11-18
How can we inactivate Alt+F4 in Access?

To be more specific, how could we guide the user to close the programme (which we have made in Access) using our button and not be able to close it, by exiting Access from X button?
0
Comment
Question by:Ulysses_s16
[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 77

Assisted Solution

by:peter57r
peter57r earned 250 total points
ID: 17137328
Hi Ulysses_s16,
The common approach to this problem is to use a hidden form and use the close event of the hidden form to do any 'closedown' processing.  Open the hidden form when the database opens, and leave it open all the time.  Then if a user closes Access the close of the hidden form can run the code in your own close button.

Pete
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 17137341
The simplest way is to not worry about trying to trap keystrokes (since users can - and will - find a way around it) and instead open a hidden form when your app opens. Run any code which needs to run at shutdown in the Close or Unload event of that form, since Access will attempt to close it at some point. If desired, you can also force the user to confirm the close:

Private Sub Form_Unload(Cancel As Integer)
    If MsgBox("Are you sure you want to close?",vbYesNo, "Confrm App Close")<> vbYes Then
      <do something here, maybe re-open you main menu or something>
      Cancel = True
    Else
      <your shutdown routine here>    
    End If
End Sub

If you have a form that is always open (and cannot be closed, either by the user or by your code) you can use this. I typically have a Main Menu form in my apps which is always open, and I run code in that form similar to this.

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

636 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