Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2006
    Posts
    559

    Unanswered: Disable shift-bypass

    So I've followed this exactly as it's written but I get a syntax error when I double-click on my command button (invisible) on the splash screen. The syntax error highlights the first MessageBox saying it's a syntax error. I can't figure it out, does anyone else know what may be wrong?


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

    Code:
    How To Disable/Enable the Shift Bypass Key in Microsoft Access: 
    QUESTION >> Is there any way of preventing user's from holding down Shift Key when opening up my Microsoft Access database and bypassing the Start-Up options which have been disabled.
    
    I however, still need some sort of facility to do this, so I can add new forms, queries etc. whenever necessary. 
    
    SOLUTION >> To prevent a user bypassing the start-up options you will need to apply the following function and code to a command button (or ideally a hidden option, such as to the double-click event of a label or graphic).
    
    This will prevent anyone without the password bypassing the start-up by using the Shift key.
    
    The below function and command button code will allow you to use a password protected input box to determine if the Shift key can be disabled or not.
    
    You might have to set your "References" in the VBA editor to DAO 3.6.
    
    When you are viewing a Module, click the Tools menu » References. Browse for Microsoft DAO 3.6
    
    Select "Files of type: Executable Files (*.exe; *.dll)"
    
    C:\Program Files\Common Files\Microsoft Shared\DAO)
    
    Then explicitly dimension yourcode, i.e. Dim db As DAO.Database, prp As DAO.Property
    
    '***************** 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 ***************Once this is in place, a user will not have access to bypass the Start-Up options.
    
    As the administrator, you can then click on your command button, label or graphic and will be presented with the following input box:
    
    
    
    If the correct password is entered you will see the following message:
    
    
    
    An inncorrect password will give the following message and not allow the Shift key to bypass the Start-Up options:
    
    
    
    Note: Always create a backup copy of the database, to test out any areas that may cause problems when working with start-up options or disabling Access features.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    boring, repetitive, i know, but my humble contrib will
    -disable bypass in the MDE
    -optionally quit the MDE if bypass attempted
    -not lock you out of the development MDB

    if you need more: why?

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388

    Bypass Problem

    I found this datbase created by a Dave Mason a few months ago whilst surfing the net. This database allows you to set the properties remotely of a selected database.The attached txt file gives you some information regarding the use.

    I have modified it for my own use by
    1. Hiding the security items as I do not use workgroups.
    2. I have added some buttons that have code behind each with the path etc for the databases I frequently set the properties.
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2004
    Location
    UK
    Posts
    82

    Remember

    If you have dissable shift to prevent users from interfering with your db, they can still create a new db and link to your protected db.

    i have changed permissions to prevent users from creating new db's on the machine that has the db installed.

    it was a while ago so i can't remember exactly how, i found in on microsoft knowledge base.

    depending on now much you want to protect your data or application you can plant a file in windows or somewhere inconspicuos and set your start up form to check for the file and quit if it is not there.

  5. #5
    Join Date
    Aug 2006
    Posts
    559
    Quote Originally Posted by Poppa Smurf
    I found this datbase created by a Dave Mason a few months ago whilst surfing the net. This database allows you to set the properties remotely of a selected database.The attached txt file gives you some information regarding the use.

    I have modified it for my own use by
    1. Hiding the security items as I do not use workgroups.
    2. I have added some buttons that have code behind each with the path etc for the databases I frequently set the properties.

    Poppa,

    Before I try this, do you know if it'll work without issues in a split db? If so, should I put the front-end on the network share, use this db (also from the network share) and then copy the front-end to the individual user terminals, OR do I have to run it from ALL the user terminals when the front-end is on it?

  6. #6
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388

    Disable Shift Key

    do you know if it'll work without issues in a split db?

    At work we have all front-ends and back-ends on a central shared drive e.g. J:\common\databases. due to the size of the work environment etc. Myself and another person are the only ones who have a copy of this database, that way we can maintain control of the "behind the scene" access.

    I have the database in my personal network folder and set the properties of the databases so that only the status appears. When I want to fix to problem with a front end or back end I then use this database to set the properties to allow access to make changes etc.

    do I have to run it from ALL the user terminals when the front-end is on it?
    This would defeat the purpose as the user with a bit of knowledge would be able to make changes etc.

    I suggest you use try this database on a copy of one of your databases that is not using "live data"

  7. #7
    Join Date
    Aug 2006
    Posts
    559
    Poppa,

    I tried that when I was at work but got an error when I did. I forgot what it was but will try to recreate it tonight / tomorrow and let you know what it is.

Posting Permissions

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