Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Inactivate Alt+F4 in Access (the x Button)

Posted on 2006-07-19
2
Medium Priority
?
369 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 750 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 750 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

877 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