Solved

Inactivate Alt+F4 in Access (the x Button)

Posted on 2006-07-19
2
358 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 84

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

763 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