Solved

Inactivate Alt+F4 in Access (the x Button)

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Query Missing Money orders... 6 72
SharePoint 2013 Relational Database 8 23
select over clause 1 10
Minus first query 1 0
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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 how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now