Solved

Inactivate Alt+F4 in Access (the x Button)

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

839 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