Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011

    Unanswered: Disable the Bypass Key

    Howdy,

    I used the following code on a regular basis to disable the ByPass key, but for some reason, it no longer works in my Access 2003.
    When I trace it, it never actually creates the property - prp remains nothing the whole time.
    Code:
    Sub SetBypass(blSet As Boolean)
    
        Dim prp As Property
        
        On Error Resume Next
        CurrentDb.Properties("AllowBypassKey") = blSet
        If Err Then
            Err.Clear
            Set prp = CurrentDb.CreateProperty("AllowBypassKey", dbBoolean, blSet)
            CurrentDb.Properties.Append prp
            Set prp = Nothing
        End If
    End Sub
    Any ideas?
    tc

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I use a generic property wrapper like so:

    Code:
    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
    The AllowBypassKey setting looks like this:
    Code:
    Sub SetBypassProperty(boolIn As Boolean)
    Const DB_Boolean As Long = 1
        ChangeProperty "AllowBypassKey", DB_Boolean, boolIn
    End Sub

    Haven't had a problem with it yet.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    are you getting err 3270 or something else?
    does dbboolean work for you in immediate? (if no, try 1)

    i much prefer the belt & braces approach of checking the err.number:

    on error goto err_xx
    'set here
    exit_xx:
    exit sub
    err_xx:
    select case err.number
    case 3270
    'append here
    'resume exit_xx
    case else
    'do something intelligent
    resume exit_xx
    end select
    end sub

    ...and it DOES work in A2K3 for me.

    izy


    Hmmmm: Teddy types faster than me
    currently using SS 2008R2

  4. #4
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    I don't actually get an error message. If I set On Error GoTo 0 and step through the code, it simply hops out of the procedure when it gets to the line where it is supposed to create the property. No error message is generated, but it clearly encounters an error.

    I've had no problems with this property (or this routine) in other instances, including running in Access 2003. I'm thinking there is a setting of some sort in Access 2003 I'm not familiar with (I just started using 2003 recently).

    I will try Teddy's code tomorrow when I get back to work.

    In break mode, the contant dbBoolean does give me the 1. I generally pursue error numbers more thuroughly, but I've never had a problem with this routine before.

    tc

Posting Permissions

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