Results 1 to 4 of 4

Thread: By Pass Shift

  1. #1
    Join Date
    Sep 2002
    Location
    california
    Posts
    31

    Unanswered: By Pass Shift

    Ok I'm trying to make it so that my Access 2002 mde file cannot be opened with a shift key. I have looked and looked and I have found some code out there, but no where can I find what to do with the code, where to place it.
    Can anyone help me? What am I missing?
    Thanks so much for you time and consideration.
    Debbie

  2. #2
    Join Date
    Jan 2003
    Location
    Rockville, MD
    Posts
    179
    Hi Debbie,

    This code sample was taken from Microsoft Access Help (I added the bolded lines, cuz I'm a stickler for closing things)
    Code:
    Sub SetBypassProperty()
    Const DB_Boolean As Long = 1
        ChangeProperty "AllowBypassKey", DB_Boolean, False
    End Sub
    
    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
        Dim dbs As Object, prp As Variant
        Const conPropNotFoundError = 3270
    
        Set dbs = CurrentDb
        On Error GoTo Change_Err
        dbs.Properties(strPropName) = varPropValue
        ChangeProperty = True
        dbs.close
         set dbs = nothing
    
    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
    To use it:
    Open your database (mdb).
    Create a new module.
    Paste this code into it.
    Run the "SetBypassProperty" subroutine by positioning your cursor in the function, then press F5 (or click run).
    Close your database without saving the newly created module.

    You now have successfully blocked the ability to open the database while using the shift key.

    Make the mde for distribution purposes.

    If you choose, you can set the property back to true by repeating the steps above, but changing the occurance of "False" in sub SetBypassProperty to "True" before running it.

    You can also keep this code in another database, and change this line to indicate the mdb you want to change the property for.

    Change

    Set dbs = CurrentDb

    to

    Set dbs = OpenDatabase("C:\MyFolder\MyDatabase.mdb")

    Is that what you were looking for?
    JT

  3. #3
    Join Date
    Sep 2002
    Location
    california
    Posts
    31

    Talking

    Yes this is just what I needed. Thanks so much. There are some things about Access that I know very well, but I have a hole here and there. Thanks for such a complete explanation.
    Debbie

  4. #4
    Join Date
    Jul 2003
    Location
    Portugal
    Posts
    111

    Congratulations!

    Here is the most wonderfull way to explain well and clear this subject.
    Congratulations!

    Ruas


    Originally posted by JTRockville
    Hi Debbie,

    This code sample was taken from Microsoft Access Help (I added the bolded lines, cuz I'm a stickler for closing things)
    Code:
    Sub SetBypassProperty()
    Const DB_Boolean As Long = 1
        ChangeProperty "AllowBypassKey", DB_Boolean, False
    End Sub
    
    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
        Dim dbs As Object, prp As Variant
        Const conPropNotFoundError = 3270
    
        Set dbs = CurrentDb
        On Error GoTo Change_Err
        dbs.Properties(strPropName) = varPropValue
        ChangeProperty = True
        dbs.close
         set dbs = nothing
    
    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
    To use it:
    Open your database (mdb).
    Create a new module.
    Paste this code into it.
    Run the "SetBypassProperty" subroutine by positioning your cursor in the function, then press F5 (or click run).
    Close your database without saving the newly created module.

    You now have successfully blocked the ability to open the database while using the shift key.

    Make the mde for distribution purposes.

    If you choose, you can set the property back to true by repeating the steps above, but changing the occurance of "False" in sub SetBypassProperty to "True" before running it.

    You can also keep this code in another database, and change this line to indicate the mdb you want to change the property for.

    Change

    Set dbs = CurrentDb

    to

    Set dbs = OpenDatabase("C:\MyFolder\MyDatabase.mdb")

    Is that what you were looking for?
    JT

Posting Permissions

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