Disable Shift Key Bypass (2 Viewers)

TheSearcher

Registered User.
Local time
Yesterday, 23:38
Joined
Jul 21, 2011
Messages
365
I'm trying to disable the Shift Key Bypass functionality. I found the following methodology in an AI website. It seems simple enough but it doesn't work. Can anyone help? I want the autoexec macro to run even if the Shift key is held down.

To disable the shift key bypass in Microsoft Access, you need to modify the AllowBypassKey property to False using VBA code. This will prevent users from holding the shift key down while opening the database to bypass startup options like the AutoExec macro and the specified startup form.
Here's how to do it:
1. Open the VBA Editor: In Access, press Alt + F11 to open the Visual Basic Editor.
2. Go to Immediate Window: In the VBA Editor, navigate to View > Immediate Window.
3. Enter the Code: Type or paste the following code into the Immediate Window and press Enter:
Code
CurrentProject.Properties.Add "AllowBypassKey", False
1. Close the Editor: Close the VBA Editor.
2. Close and Reopen Access: Close and then reopen the Access database to test the change.
Now, holding down the shift key while opening the database will no longer bypass the startup options.
 
i use this.
the apEnableShift reverses all settings

Code:
Function apDisableShift() As Boolean
    'This function disable the shift at startup. This action causes
    'the Autoexec macro and Startup properties to always be executed.

    On Error GoTo errDisableShift

        Dim db As DAO.Database
        Dim prop As DAO.Property
        Const conPropNotFound = 3270
        Dim sProp As String
        
        Set db = OpenDatabase(CurrentProject.Path & "\" & [Forms]![frmMenu]![cmbDBName])
        Check4MdbProps db
        
        db.Properties("StartUpShowDBWindow") = False
        db.Properties("StartUpShowStatusBar") = False
        db.Properties("AllowFullMenus") = False
        'enable F11, ALT F11, etc. for short key
        db.Properties("AllowSpecialKeys") = False
        'allow Access Shortcut Menus. May be too severe
        db.Properties("AllowShortcutMenus") = False
        db.Properties("AllowToolbarChanges") = False
        
        sProp = "AllowByPassKey"
        db.Properties("AllowByPassKey") = False

        sProp = "AllowBreakIntoCode"
        db.Properties("AllowBreakIntoCode") = False
        
        apDisableShift = True
endit:
        'The function is successful.
        Exit Function

errDisableShift:
'MsgBox Err.Description & vbCrLf & "prop:" & sProp, , "apDisableProps:" & Err
'Resume endit
'Resume
    'The first part of this error routine creates the "AllowByPassKey
    'property if it does not exist.
On Error Resume Next
    If Err = conPropNotFound Then
        Set prop = db.CreateProperty("AllowByPassKey", dbBoolean, False)
        db.Properties.Append prop
        Resume Next
        Else
        'MsgBox "Function 'apDisableShift' did not complete successfully."
        'Exit Function
    End If
    Resume Next
End Function
 
Whilst the shift bypass can be disabled with code such as that above, it can also be re-enabled externally from another database.
For more details and code, see my article:
 
Okay. I realize this is probably a stupid question - but how do I get back in after the shift key bypass is disabled? What if I want to turn it off so that I can modify something?
 
Okay. I realize this is probably a stupid question - but how do I get back in after the shift key bypass is disabled? What if I want to turn it off so that I can modify something?

See my first sentence in post #4. Details are in my article.
However, remember just as you will be able to get back in using suitable code, so can other knowledgeable users.

You should also keep a copy that isn't locked down for future development work
 
Don't necessarily have to re-enable just to do edits. Depends on what other customization you implement. Have you employed a modified ribbon? Have you disabled right click shortcut menus? Do you hide Navigation Pane? Disable function keys?

If you can still go to the VBA Editor, you can do whatever code edits you want.

Some will encrypt database so VBAEditor can only be accessed by password. Or deploy an executable frontend to users.
 
@June7 - I hide the ribbon, hide the navigation pane and disabled all Access close out buttons. How can I get to the module that contains my function? Can I still get to the VBA editor?
 
@isladogs - I have not. I'm not familiar with that. What does Ctrl+G do?
Also, I tried your code that you provided in your article and it worked beautifully. I was able to reverse the code from another database. Very elegant. Thanks!
 

Users who are viewing this thread

Back
Top Bottom