Results 1 to 5 of 5
  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 set this up once but I think I forgot something. I have a module with the codes to turn the key on and off

    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 "Your Database is Paused Hit OK"

    End Function

    Function NoByPass()

    CurrentDb.Properties("AllowBypassKey") = False
    MsgBox "Your Database is Running"

    End Function

    and I have buttons to run the functions when needed. but I think I need to have something load up with the database to make it work. If I run the module manualy the functions work but when I close and open the database it needs to be run again. How can I get it so that this will work automatically every time the DB is opened.

  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))

    YOu need to either create an AutoExec macro or set a startup form to call the code.
    Charlotte

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: AllowBypassKey (2002 (XP))

    Is this different in XP (and 2000?) from 97? I thought that AllowByPassKey was a database property; once you set it, it is stored in the database and stays effective until you reset it. I have Access 97 databases without an AutoExec macro or startup form code, but the shift key is disabled or enabled according to the value of the AllowByPass property (the property has been created using code similar to the code posted here).

  4. #4
    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))

    No it hasn't changed, but I'm not sure we read the question the same way.
    Charlotte

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Jacksonville,NC, USA
    Posts
    705
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AllowBypassKey (2002 (XP))

    Did you check it beside the script that you can copy in HELP within Access. Click the Office Asst., type in Disable Shift key and then click on Allow Bypass key, and look for the example, and click on the word example. You will need to copy the entire code to the clipboard. Close the help window and click Modules in the objects bar of the Main Database window. Click the New button to create a standard module. Right-click in the module window to paste the code you just copied. Save the file as basFunctions. and then click OK. Double-click the word Sub in the first line of the code to select it, and then type Function, and press the down arrow key on your keyboard. Note that the End sub line of code changes automatically to End Function.
    Position the insertion point between the parenthesis in the first line of the SetByPass property function. Type bValue As, and then press the spacebar. Type B, and the list shows the items that begin with B. Doubl-click Boolean to complete the statement. Select the word False in the ChangeProperty statement, and type bValue. Save and close the window, choosing File...Close and Return.
    Now create your automacro key group for whatever keyboard shortcut you want to use (as the administrator) to get around your protected startup settings when you need to edit.
    Charlotte is correct (as always) that you need to make a macro named Autoexec, so it opens your Main Switchboard or Master Form every time you open the database. It just has to exist for that purpose alone.
    Not sure if all is well for you already, but thought I throw in a couple extra cents to be sure. I get so much help from others in here, trying to pay some of it back.
    I am going to edit this message, and insert that code here, so you can copy it if you need to:

    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

    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


    Good Luck
    NMPadgett [img]/forums/images/smilies/smile.gif[/img]
    NMP <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

    If you can't convince them, confuse them. - Harry Truman <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

Posting Permissions

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