Reputation: 93
I disabled the startup options of my access project(.accdb) using this code from Microsoft. And it worked after I type in the immediate window to disable to shift key.
But how can I re enable the shift key again since I cannot go through with the code anymore since it is now hidden and all I can see now is this.
Any idea how can I view the immediate window again to enable the shift key?
Upvotes: 1
Views: 2365
Reputation: 6336
Enable Bypass key from VBA code in another database. This will be the only way if also disabled special keys like Alt-F11. Here is modified code from Microsoft site. Create this function in another database and modify path to your protected database:
Function ap_EnableShift()
'This function enables the SHIFT key at startup. This action causes
'the Autoexec macro and the Startup properties to be bypassed
'if the user holds down the SHIFT key when the user opens the database.
On Error GoTo errEnableShift
Dim db As DAO.Database
Dim prop As DAO.Property
Const conPropNotFound = 3270
Set db = OpenDatabase("C:\path\tst.accdb")
'This next line of code enables the SHIFT key on startup.
db.Properties("AllowByPassKey") = True
'function successful
Exit Function
errEnableShift:
'The first part of this error routine creates the "AllowByPassKey
'property if it does not exist.
If Err = conPropNotFound Then
Set prop = db.CreateProperty("AllowByPassKey", _
dbBoolean, True)
db.Properties.Append prop
Resume Next
Else
MsgBox "Function 'ap_DisableShift' did not complete successfully."
Exit Function
End If
End Function
Upvotes: 3