ShiftBypass Disable

XLEAccessGuru

XLEGuru
Local time
Today, 12:38
Joined
Nov 17, 2006
Messages
65
:eek:

Hey all,

I've been using this SetProperties code successfully in databases for some time now. I added it to another database but all of a sudden I'm getting "property not found" error on the line

Code:
'dbs.properties(strPropName)=varPropValue

There is a trap in there (see full function below) that is supposed to take care of this error but it's not working. I've checked all my references and they are all there as they should be so it's not a reference issue.

Any ideas why the trapper isn't working??? Please help - I'm desperate to fix this. I can't use Access user-level security for this lockdown so I really need this to work - and REAL soon. Thanks fellow gurus!

Code:
Function SetProperties(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
    SetProperties = 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.
        SetProperties = False
        Resume Change_Bye
    End If
End Function
 
prp is being declared as a Variant type, try declaring it as a Property type and see what that does.
 
Thanks DJkarl, but it didn't work. Any other ideas? I'm really confused cause I don't have this problem in any of my other dbs!
 
Thanks DJkarl, but it didn't work. Any other ideas? I'm really confused cause I don't have this problem in any of my other dbs!

Are you getting an error in the error handler? Or what exactly is happening?

What are you passing to this function?
 
You should really be reporting all of the other error numbers and descriptions so you can troubleshoot the problem.
 

Users who are viewing this thread

Back
Top Bottom