Enable|Disable SHIFT key

aziz rasul

Active member
Local time
Today, 21:28
Joined
Jun 26, 2000
Messages
1,935
I have found the following code, which is placed behind two command buttons on an opening form.

Code:
Private Sub cmdEnableSHIFTKey_Click()

    Dim db As Database
    
    Set db = CurrentDb
    
    db.Properties.Delete "allowbypasskey"
    db.Properties.Refresh

End Sub

Private Sub cmdDisableSHIFTKey_Click()

    Dim db As Database
    Dim prp As Property
    
    On Error GoTo ErrorHandler
    
    Set db = CurrentDb
    
    Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, False)
    db.Properties.Delete "AllowBypassKey"
    db.Properties.Append prp
    
ErrorHandler:
    If Err.Number = 3265 Then
        Resume Next
    End If

End Sub

When I press the cmdDisableSHIFTKey button and close the db and then open it, the db window still appears. I'm using Access 2010.
 
Last edited:
Hi Aziz,
It looks as though this code only disables the shift key, which only stops someone opening the database in Admin mode. This does not hide the navigation pane in 2010 as it did in earlier versions.
I have found another thread on this message board that deals with hiding the navigation pane programmatically.
http://www.access-programmers.co.uk/forums/showthread.php?t=217400

I hope this answers your question.
 
Didn't work I'm afraid. The db sits on a network. Does this make a difference?
 
Glad you found something. There's a number of ways you can protect your database. Putting a password on your code is a good start, also deploying your database as a .mde/.accde instead of .mdb/.accdb stops people from being able to change most objects.

You could also alter the code you posted eariler in the thread to include password input, something like the following:

Code:
Private Sub cmdEnableSHIFTKey_Click()
 
Dim db As Database
Dim Input as String
Dim Message as string
 
Set db = CurrentDb
 
Message = "Input password to allow shift key"
Input = InputBox(Prompt:=Message, Title:="Enable Shift Key Password")
 
If Input = "EnterPasswordHere" Then
db.Properties.Delete "allowbypasskey"
db.Properties.Refresh
Else
msgbox "Incorrect password"
End if
 
End Sub

This needs neatening up I guess, but gives you a flavour of what you could do. I personally wouldn't worry about putting the password string into the VBA code, because I would lock that down with a password anyway.

I'm sure there are others here who might have better ideas on this subject.
 
Both good suggestions. Many thanks. Will try them.
 

Users who are viewing this thread

Back
Top Bottom