Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    Jan 2003
    Location
    Toledo, Ohio, USA
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disabling Shift key at startup

    How do I disable users from being able to access the db container via holding the shift key when a database is started?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Disabling Shift key at startup

    Tools-->Startup-->Advanced. Uncheck Use Access Special Keys.

    However, you had better have a back door somewhere on a form or in your code so that YOU can get back into it yourself.
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Jan 2003
    Location
    Toledo, Ohio, USA
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling Shift key at startup

    Hmmm - that is what I did (in Access 97), and when I hold the shift key down and start the database, the database container/window still appears.

  4. #4
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling Shift key at startup

    Try this, I have this code running from a button in another database to 'lock' the target database

    Private Const szDatabaseToControl = "xxx.mde"

    Private Sub Command1_Click()
    Dim db As Database, ws As Workspace
    Set ws = DBEngine.Workspaces(0)
    Set db = ws.OpenDatabase(szDatabaseToControl)

    ChangeProperty db, "AllowBypassKey", dbBoolean, False
    End Sub
    Function ChangeProperty(dbs As Database, strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim prp As Property
    Const conPropNotFoundError = 3270

    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
    ' Unknown error.
    ChangeProperty = False
    Resume Change_Bye
    End If
    End Function

  5. #5
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling Shift key at startup

    Charlotte,

    I thought this option was meant to stop things such as the F11 key shortcut when the database is open, not the Shift key combination on startup.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Disabling Shift key at startup

    It should do both.
    Charlotte

  7. #7
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Newtown, Pennsylvania, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling Shift key at startup

    Any reason for not using AllowBypassKey, other than wanting a way to ensure that the programmer can get in?

    I found this command in both Access 97 and 2000 help files.

    Kiwi44

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling Shift key at startup

    Charlotte - No, turning off "Use Access Special Keys" does not disable the shift key. It certainly doesn't in A97 (I use both it and the AllowByPassKey property a lot). I'm 99% certain it also does not in A2000, but I'd have to double-check to be absolutely certain.

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Disabling Shift key at startup

    [Loud sound of hand smacking forehead]!!![img]/w3timages/icons/doh.gif[/img] You're quite right. I've had startup code standardized for so long that I forgot that was one of the properties I set that way.[img]/w3timages/icons/blush.gif[/img]
    Charlotte

  10. #10
    2 Star Lounger
    Join Date
    Jan 2003
    Location
    Toledo, Ohio, USA
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling Shift key at startup

    So does this mean that the shift key cannot be disabled during startup?

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Disabling Shift key at startup

    Yes, it can. But you have to do it from code. There isn't any handy setting to turn the bypass key off. See Andy's post earlier in the thread for code that will work in either Access 97 or Access 2000 (with a DAO reference set).
    Charlotte

  12. #12
    Mike B
    Guest

    Re: Disabling Shift key at startup

    is this what you are looking for...

    basDisableShiftKey
    Option Compare Database
    Option Explicit

    Function StopShift()
    'The next time the database is opened the Shift key is disabled. Start Up options and AutoExec macro will be executed, even if the user starts the database holding down the Shift key. Call this function from the macro "mcrStopShift". The AllowByPassKey is a user defined property that must be created before it can be set. The first time this function is executed you may get error 3270. The error handling will create the property.

    Dim db As Database
    Dim propShift As Property

    On Error GoTo StopShiftError

    Set db = CurrentDb
    db.Properties("AllowByPassKey") = False
    MsgBox "The Shift key is disabled. Close and restart the database " & "in order to activate the change.", vbOKOnly + vbInformation,"Disable/Enable Shift key"
    Exit Function

    StopShiftError:
    If Err.Number = 3270 Then
    Set propShift = db.CreateProperty("AllowByPassKey", dbBoolean, True)
    db.Properties.Append propShift
    Resume
    Else
    MsgBox "The Shift key was not disabled." & vbCrLf & "Reason: " & Err.Number & Err.Description, vbOKOnly + vbInformation, "Disable/Enable Shift key"
    End If
    End Function

    Function StartShift()
    The next time the database is opened the Shift key is enabled again Start Up options and AutoExec macro will only be executed if the user starts the database without holding down the Shift key. Call this function from the macro "mcrStartShift". Open the database with the syntax:
    "<Access path>/MSACCESS.EXE" "<database path>/<database name>" /x <macro name>
    The AllowByPassKey is a user defined property that must be created before it can be set. The first time this function is executed you may get error 3270. The error handling will create the property.

    Dim db As Database
    Dim propShift As Property

    On Error GoTo StopShiftError

    Set db = CurrentDb
    db.Properties("AllowByPassKey") = True
    MsgBox "The Shift key is enabled. Close and restart the database " & "in order to activate the change.", vbOKOnly + vbInformation, "Disable/Enable Shift key"
    Exit Function

    StopShiftError:
    If Err.Number = 3270 Then
    Set propShift = db.CreateProperty("AllowByPassKey", dbBoolean, True)
    db.Properties.Append propShift
    Resume
    Else
    MsgBox "The Shift key was not enabled." & vbCrLf & "Reason: " & Err.Number & Err.Description, vbOKOnly + vbInformation, "Disable/Enable Shift key"
    End If
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •