How to Disable Shift and F11 Keys

D

DevDaniel

How do I programatically:
1. disable the shift key when the database is opened
2. disable the F11 key to keep the the database window hidden

Thanks for your help!

Dan
 
W

Warren

This is a bit crude but I use and it and it does exactly what I need.

I have a 'secret' area (a box) on the open screen of my database where
the frontend is an MDE file. The click event does this:

Dim Pass As String
Dim db As Database
Dim prp As Property

Pass = InputBox("Password:", "Password")
If Pass = "YOUR PASSWORD" Then
Dim Response
Response = MsgBox("Lock = 'YES'" & vbCrLf & "Unlock = 'NO'",
vbYesNo, "Unlock")
If Response = vbYes Then
'This Code Disables the Shift Key
Set db = CurrentDb
Set prp = db.CreateProperty("AllowByPassKey", dbBoolean,
False)
db.Properties.Append prp

Else
'This Code Enables the Shift Key
Set db = CurrentDb
db.Properties.Delete "AllowByPassKey"
db.Properties.Refresh
End If
Else
End If
Set db = Nothing
Set prp = Nothing


When I 'unlock' the shift key, I exit then re-open holding shift!

Like I said, crude but works.


Warren
 
M

Manuel

This is helpful, but how do you go about disabling the Shift key to begin
with? I'm using the below code I took from:

http://www.databasedev.co.uk/disable_shift_bypass.html

'***************** Code Start ***************
'Copy this function into a new public module.

Option Compare Database
Option Explicit

Public Function SetProperties(strPropName As String, _
varPropType As Variant, varPropValue As Variant) As Integer

On Error GoTo Err_SetProperties

Dim db As DAO.Database, prp As DAO.Property

Set db = CurrentDb
db.Properties(strPropName) = varPropValue
SetProperties = True
Set db = Nothing

Exit_SetProperties:
Exit Function

Err_SetProperties:
If Err = 3270 Then 'Property not found
Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "SetProperties", Err.Number, Err.Description
Resume Exit_SetProperties
End If
End Function
'***************** Code End ***************Once you have created the module,
then you will need to attach the following code to a command button (or
label, graphic etc.):

'***************** Code Start ***************
'Assign this to the OnClick event of a command button (or double-click event
'of a label or graphic) named "bDisableBypassKey"
'Change the "TypeYourBypassPasswordHere" default password to your password

Private Sub bDisableBypassKey_Click()
On Error GoTo Err_bDisableBypassKey_Click
'This ensures the user is the programmer needing to disable the Bypass Key
Dim strInput As String
Dim strMsg As String
Beep
strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
"Please key the programmer's password to enable the Bypass Key."
strInput = InputBox(Prompt:=strMsg, title:="Disable Bypass Key Password")
If strInput = "TypeYourBypassPasswordHere" Then
SetProperties "AllowBypassKey", dbBoolean, True
Beep
MsgBox "The Bypass Key has been enabled." & vbCrLf & vbLf & _
"The Shift key will allow the users to bypass the startup & _
options the next time the database is opened.", _
vbInformation, "Set Startup Properties"
Else
Beep
SetProperties "AllowBypassKey", dbBoolean, False
MsgBox "Incorrect ''AllowBypassKey'' Password!" & vbCrLf & vbLf & _
"The Bypass Key was disabled." & vbCrLf & vbLf & _
"The Shift key will NOT allow the users to bypass the & _
startup options the next time the database is opened.", _
vbCritical, "Invalid Password"
Exit Sub
End If
Exit_bDisableBypassKey_Click:
Exit Sub
Err_bDisableBypassKey_Click:
MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
Resume Exit_bDisableBypassKey_Click
End Sub
'***************** Code End ***************
 
D

Douglas J. Steele

That code's essentially the same code to which I pointed.

Since you've got code, I'm afraid I don't understand your question. You run
that code to disable the Shift key!
 
J

jutlaux

Doug,
Not sure if you still are montioring this post or not, but thought I would
try. I've been using the code at the line you posted
http://www.mvps.org/access/general/gen0040.htm for sometime now. I recently
upgrade to access 2007 and now cannot get this to work. When I goto complile
this it errors out on the statement:

Dim db As DAO.Database, prp As DAO.Property

I get an error of "Compile error: User-defined type not defined"

Any ideas?

Thanks,

Justin
 
J

John W. Vinson

Doug,
Not sure if you still are montioring this post or not, but thought I would
try. I've been using the code at the line you posted
http://www.mvps.org/access/general/gen0040.htm for sometime now. I recently
upgrade to access 2007 and now cannot get this to work. When I goto complile
this it errors out on the statement:

Dim db As DAO.Database, prp As DAO.Property

I get an error of "Compile error: User-defined type not defined"

Any ideas?

Open the VBA editor and select Tools... References. Make sure that the
Microsoft DAO object library (highest version) is selected.
 
D

Dirk Goldgar

John W. Vinson said:
Open the VBA editor and select Tools... References. Make sure that the
Microsoft DAO object library (highest version) is selected.


In Access 2007, I think it's the "Microsoft Access 12.0 database engine
object library", or something wordy like that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top