Results 1 to 7 of 7
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Run time error 13 (Access 2002)

    I keep getting a Run time error 13 when I try to run the following command:
    Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
    The value of strPropName can be one of :
    AllowBreakIntoCode or
    Allow BypassKey

    Yet in another database it works fine. Both lots of references are similar, the one where it does not work has an extra reference to Microsoft ActiveX Data Objects 2.1 Library, I have since changed this to 2.7 and it still does not work.

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

    Re: Run time error 13 (Access 2002)

    Are you dimming prp as a DAO.Property? Otherwise, depending on the order of references, it may be interpreted as an ADODB.Property, which has different characteristics and syntax from the DAO version.
    Charlotte

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Run time error 13 (Access 2002)

    Charlotte, thanks for responding. The code is entered via a call to SetStartupPropertiesONLINE the OnOpen event of the login form frmLogin.

    <pre>Sub SetStartupPropertiesDEVELOPMENT()
    ChangeProperty "StartupForm", dbText, ""
    ChangeProperty "StartupShowDBWindow", dbBoolean, True
    ChangeProperty "StartupShowStatusBar", dbBoolean, False
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, True
    ChangeProperty "AllowFullMenus", dbBoolean, True
    ChangeProperty "AllowBreakIntoCode", dbBoolean, True
    ChangeProperty "AllowSpecialKeys", dbBoolean, True
    ChangeProperty "AllowBypassKey", dbBoolean, False

    End Sub
    Sub SetStartupPropertiesONLINE()
    ChangeProperty "StartupForm", dbText, "frmLogin"
    ChangeProperty "StartupShowDBWindow", dbBoolean, False
    ChangeProperty "StartupShowStatusBar", dbBoolean, False
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
    ChangeProperty "AllowFullMenus", dbBoolean, False
    ChangeProperty "AllowBreakIntoCode", dbBoolean, False
    ChangeProperty "AllowSpecialKeys", dbBoolean, False
    ChangeProperty "AllowBypassKey", dbBoolean, False

    End Sub

    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim dbs As Database, prp As Property
    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
    </pre>


    The AllowBreakIntoCode is where the error occurs. If I bypass this error then AllowBypassKey errors with the Error 13.

  4. #4
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Run time error 13 (Access 2002)

    I believe Charlotte was suggesting that you change your Dim line so you declare prp "As DAO.Property" rather than "As Property".

    If the ADO library is above the DAO library in the database's list of References, Access will interpret "As Property" as referring to an ADO Property unless you explicitly declare it as a DAO.Property.

    Alternatively, you can rearrange your list of References, but explicitly declaring that kind of variable is a good idea in any case. It means you can move your code from one database to another without having to worry about the References order.

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Run time error 13 (Access 2002)

    You and Charlotte were right on the money.

    I am puzzled though as to why. Why would it do the first 5 ok, then not the 6th, then the 7th ok, then not the 8th. It's a mystery to me.
    Also this code was the same in the other database I mentioned and it always worked.

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

    Re: Run time error 13 (Access 2002)

    It might work on properties that already exist but break when it had to create one because it couldn't reconcile the ADO property with the DAO database object. Some properties might only exist by that name in DAO, I suppose, which would allow the jet engine to reconcile the reference on the fly. In the other database, you may not have had an ADO reference set or the DAO reference may have been higher in the list. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

  7. #7
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Run time error 13 (Access 2002)

    Sounds logical when you explain it.

Posting Permissions

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