Results 1 to 10 of 10
  1. #1
    Star Lounger
    Join Date
    Jan 2002
    Location
    Massachusetts, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AllowBypassKey (2002 (XP))

    I'm trying to find where I set this key. I want to turn it off and then create a keystroke to turn it back on and I'm not sure of how or the code to do it. My hope is that I will be able to hit this key combo while the db is open and then I can close the db and when I reopen it the shift key will work. Then if I hit the key stroke again it will be disabled.

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

    Re: AllowBypassKey (2002 (XP))

    It is possible to do it in the code behind a button. Open an Access module in design view and click Help. Type AllowByPassKey into the AnswerWizard "what would you like to do" box, and the first item on the list should be AllowBypassKey Property, complete with a code example. If you need any help making that work behind a button, post back to this thread with specifics on the problem.
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Jan 2002
    Location
    Massachusetts, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AllowBypassKey (2002 (XP))

    charlotte,

    I grabbed the code and put it in an event proceedure tied to the click on a button but it throws error. Help!!!

  4. #4
    Star Lounger
    Join Date
    Jan 2002
    Location
    Massachusetts, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AllowBypassKey (2002 (XP))

    Char,

    I made a module called basBypass and when I run it from VB it works (Problem is now I get back in but that is OK cause I used a copy of the original) Now how do I tie that module to a button. I hope the code acts like a toggle and reverses allowbypasskey each time it is run.

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

    Re: AllowBypassKey (2002 (XP))

    You call the routine from the code behind the command button. The function SetBypassProperty() was included in the example as a demonstration of how to call the ChangeProperty function in order to set the AllowBypassKey to false. If you want to turn it back on, you need to call ChangeProperty and set AllowBypassKey to True. Does that explain it? If you want to toggle the event from the command button, put the call to ChangeProperty directly into the button's Click event procedure and use something like this:

    <pre>Private Sub cmdToggle_Click()
    Dim blnBypassOn As Boolean

    On Error GoTo cmdToggle_err

    blnBypassOn = CurrentDb.Properties("AllowByPassKey")
    ChangeProperty "AllowBypassKey", DB_BOOLEAN, Not blnBypassOn

    cmdToggle_exit:
    Exit Sub
    cmdToggle_err:
    <font color=448800>'if the property doesn't exist, it is considered True and
    'will be created when ChangeProperty is first called</font color=448800>

    If Err = 3270 Then
    blnBypassOn = True
    Resume Next
    End If
    End Sub</pre>

    Charlotte

  6. #6
    Star Lounger
    Join Date
    Jan 2002
    Location
    Massachusetts, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AllowBypassKey (2002 (XP))

    OK, I found this code that looks like it should do what I want.

    Option Compare Database
    Option Explicit

    Sub SetByPassProperty()
    Const DB_Boolean As Long = 1
    ChangeProperty "AllowBypassKey", DB_Boolean, False
    End Sub

    'This function disable the Shift Key from pausing the database start up and allowing users to underlying tables, queries,
    'etc. Even though they can hold the shift key down, it will not stop that "startup" sequence.

    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant)
    Dim dbs As Object, prp As Variant
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo Change_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

    Change_Bye:
    Exit Function

    Change_Err:
    If Err = conPropNotFoundError Then
    Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
    dbs.Properties.Append prp
    Resume Next

    Else

    ChangeProperty = False
    Resume Change_Bye

    End If
    End Function

    'Use a hidden "back-door" to run this function. If not, then you may not get back in.

    Function AllowByPass()

    CurrentDb.Properties("AllowBypassKey") = True
    MsgBox "What's Uppppp!"

    End Function

    The problem is where do I put it? and how do I make it work? It looks like there are 2 functions here how to I call them (Do I make 2 Macros, one to allowbass and one to not allow bypass) I pasted this into a new Module and I could run the code from the module but I don't know how to run it from a button.

    Sorry I'm so thick on this one

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

    Re: AllowBypassKey (2002 (XP))

    Did you read my previous post at all? The code I posted runs from behind a button on a form. You still have to have a module containing the function ChangeProperty to make it work. What other information do you need?
    Charlotte

  8. #8
    Star Lounger
    Join Date
    Jan 2002
    Location
    Massachusetts, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AllowBypassKey (2002 (XP))

    I'm sorry, I guess I'm in a bit over my head in this one. I'm confused about the module thing. When I attach your code to a button it won't work for me. thought I needed a module with that other code in it. I think I'll chuck this one for now. Thanks for the help though.

  9. #9
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: AllowBypassKey (2002 (XP))

    I don't know if this will simplify things or not, I created small sample database that illustrates how you can turn the AllowBypassKey property on and off using a simple popup form. Attached DB file (Access 2000 format) has only 2 objects: a form (frmShiftBypass) and a code module (modShiftBypass). The form has two command buttons: the ALLOW SHIFT BYPASS button allows user to bypass startup options by using the Shift key. The PREVENT SHIFT BYPASS button prevents user from bypassing startup options. The command buttons use following code:
    <pre>Private Sub cmdAllowBypass_Click()
    SetAllowBypass True
    GetBypassProperty
    End Sub

    Private Sub cmdPreventBypass_Click()
    SetAllowBypass False
    GetBypassProperty
    End Sub</pre>

    The GetBypassProperty is sub in form module that gets current AllowBypassKey value and toggles the caption of label on form so you know what current Shift Bypass status is. The SetAllowBypass procedure is found in modShiftBypass module (only sub in module) and sets AllowBypassKey property to True or False. The code is similar to the other examples previously posted:
    <pre>Public Sub SetAllowBypass(bAllowBypass As Boolean)
    On Error GoTo Err_Handler

    'bAllowBypass = True - allows Shift Bypass Key to be used
    'bAllowBypass = False - prevents Shift Bypass Key from being used

    Dim strMsg As String
    Dim strPropName As String
    Dim db As DAO.Database
    Dim prop As DAO.Property
    Set db = CurrentDb
    strPropName = "AllowBypassKey"
    db.Properties(strPropName) = bAllowBypass

    Exit_Sub:
    Set db = Nothing
    Exit Sub
    Err_Handler:
    If Err = 3270 Then 'Property not found - create and append property
    Set prop = db.CreateProperty(strPropName, dbBoolean, bAllowBypass)
    db.Properties.Append prop
    Resume
    Else
    strMsg = "Error No " & Err.Number & ": " & Err.Description
    MsgBox strMsg, vbExclamation, "SET ALLOW BYPASS ERROR"
    End If

    End Sub</pre>

    To make use of this in your own database, import the form and module into your database. If using A2K or later you will have to set a reference to "Microsoft DAO 3.6 Object Library" (open VB Editor and select "References" in Tools menu). To test, set some startup options for the database and try turning Shift Bypass on and off, it should be simple to implement, I use similar form in some of my own projects for this purpose.

    HTH
    Attached Files Attached Files

  10. #10
    Star Lounger
    Join Date
    Jan 2002
    Location
    Massachusetts, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AllowBypassKey (2002 (XP))

    Thanks Mark, I get it now. It works great!!! This is just what I need

Posting Permissions

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