Hi, David.
If I start my database normally and then hit F11 to break into the
development environment, the close button is still disabled and I cannot exit.
As long as your code doesn't also disable the system menu, you can press
Is there any way to detect the press of F11 (from anywhere in the
application), so I can re-enable the close button?
No. There's no way to detect when the user presses <F11> from within the VB
Editor in Access 2000 and later. However, in earlier versions of Access and
when the user is in the Access Window of Access 2000 and later, <F11> can be
detected. So your solution is to press the built-in Access Window toolbar
button when in the VB Editor, then press the <F11> button which your AutoKeys
macro will use to run the following function in a standard module:
Public Function ShowDBWin() As Boolean
On Error GoTo ErrHandler
DoCmd.SelectObject acTable, "tblMyTable", True
' Code to reenable the close button goes here.
ShowDBWin = True ' Success.
Exit Function
ErrHandler:
MsgBox "Error in ShowDBWin( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear
ShowDBWin = False ' Failed.
End Function
.. . . where tblMyTable is the name of any table that exists in the database.
Actually any object in the database window will work, so if one doesn't have
any tables (uh, isn't that what a database is for?), then one may use the
name of a different object and its object type, such as acModule for the
module that contains this public function.
The AutoKeys macro is:
Macro Name: {F11}
Action: RunCode
Function Name: =ShowDBWin()
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
See
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.