Disable F11 Key

My Front end application in Access requires the fullest possible security. To this extent I am disabling the special keys so users cannot do the hold down SHIFT bypass, nor can they access the database window via the F11 key once the database is open.
Obviously I want to be able to access the code and database objects. What I need to do is have a button which enables the special keys and therefore enables the F11 key to access the database window. I can use an if statement and read the MDW file to test if it is my logon.
I am using the following Module
Public Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
   Dim dbs As Object, prp As Variant
   Const conPropNotFoundError = 3270

   Set dbs = CurrentDb
   On Error GoTo Change_Err
   dbs.Properties(strPropName) = varPropValue
   ChangeProperty = True

   Exit Function

   If Err = conPropNotFoundError Then    ' Property not found.
       Set prp = dbs.CreateProperty(strPropName, _
           varPropType, varPropValue)
       dbs.Properties.Append prp
       Resume Next
       ChangeProperty = False
       Resume Change_Bye
   End If
End Function

Public Function BypassKey(onoff As Boolean)
   Const DB_Boolean As Long = 1
   ChangeProperty "AllowBypassKey", DB_Boolean, onoff
End Function

And I am calling the code via the code in a button which is:

However, when I click on the button to call the code above, hitting F11 after does nothing. Is it possible to achieve the above?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I think you have a couple things going on here.  First of all, the "AllowBypassKey" property only applies to the Shift key which bypasses startup options, so changing that property will not have any affect on F11 (which shows the DB window).  The property you are looking for is "AllowSpecialKeys".

Now, that being said, remember that you are setting Startup options.  You can change these during runtime, but the changes won't be applied until you restart the database.  You don't even need to use code to test this.  Just change the "Allow Special Keys" option while you have the database open and you will see that the change you make will not be in effect until the DB is restarted.

Hope this helps!!
This is a lot simpler than it may at first seem.

1) Create a Macro named "AutoKeys" without the quotes
2) Select View and make sure "Macro Names" is checked so you can see the names column
3) Under the Macro Name column enter...

4) Under the Action Column on the same row you entered {F12} enter....

5) For the Function Name enter...

6) Create a module with the following code in it (contained in the code snippet below).  Once done the F11 key will do nothing besides run the function named DoNothing() which as the name suggests does nothing.


There is one thing to be aware of, if you're user has access to the Windows pull down menu and the UnHide sub menu is in it they will still be able to UnHide the Database Window if it is hidden.  To truely lock them out their access to this pull down menu needs to be removed or at the very least the UnHide sub menu needs to be removed from the default menu bar named "Menu Bar".  

That is usually enough to keep most users out of it.  If however they know something about Access they will still be able to get to the window by either writing and executing code to show the window and/or availing themselves to the Menu option previously mentioned by adding it back to the Menu Bar and/or any other Menu Bar or toolbar that is installed.  This is not terribly complicated or hard to do but in most cases it's complicated enough that youre average user will not know how.

Just ask if you need more information.  Beyond that I've found that simply Redirecting the Action of the F11 Key via the AutoKeys Macro is more than enough to keep the vast majority of users (not developers) out.

Function DoNothing()
End Function

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.