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

Change_Bye:
   Exit Function

Change_Err:
   If Err = conPropNotFoundError Then    ' Property not found.
       Set prp = dbs.CreateProperty(strPropName, _
           varPropType, varPropValue)
       dbs.Properties.Append prp
       Resume Next
   Else
     
       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:
Btpass(true)

However, when I click on the button to call the code above, hitting F11 after does nothing. Is it possible to achieve the above?
fuerteventuraAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
KlillestolConnect With a Mentor Commented:
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!!
0
 
Rick_RickardsConnect With a Mentor Commented:
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...
{F12}

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

5) For the Function Name enter...
=DoNothing()

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

0
All Courses

From novice to tech pro — start learning today.