Results 1 to 2 of 2

Thread: AllowByPassKey Property Not Found

  1. #1

    AllowByPassKey Property Not Found

    I am having an issue with the following as I attempt to create a lock on shift bypass:

    Private Sub cmdShiftBPKey_Click()'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
    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
    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 = "RPFeynman061865" Then
    SetProperties "AllowBypassKey", dbBoolean, True
    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"
    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 Sub
    MsgBox "bDisableBypassKey_Click", Err.NUMBER, Err.Description
    Resume Exit_bDisableBypassKey_Click
    '***************** Code End ***************
    End Sub
    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 Function
    If Err = 3270 Then 'Property not found
    Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
    db.Properties.Append prp
    Resume Next
    SetProperties = False
    MsgBox "SetProperties", Err.NUMBER, Err.Description
    Resume Exit_SetProperties
    End If
    End Function
    This works in a older database but in the current accdb it errs out with on this line:

    db.Properties(strPropName) = varPropValue

    Any ideas why this is happening in 32bit MS Access 365?

  2. #2
    Okay never mind! I am not at the wheel today its seems because I left the error handling to break on all errors rather than to on Unhandled errors which explains why the error trapping routine wasn't being called.

Posting Permissions

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