Hi!
In an add-in (https://github.com/AccessCodeLib/better-access-charts/tree/main/access-add-in ... BetterAccessCharts.accda ) I use CodeProject.AllForms to get the AccessObject of a form in the add-in. The AccessObject is captured correctly.
But when I try to read the properties from it, I get the error -214746725 (Method 'Properties' of object 'AccessObject' failed).
The problem occurs only when the add-in file is opened as an add-in (i.e. when CurrentDb <> CodeDb).
If the add-in file is opened directly, the code runs without errors.
What could be the cause of the error?
Are the properties protected from access from "outside" (not CurrentProject)?
Code from BacChartConfigurationTools.cls
/edit:
ao.Isloaded works.
This is a special case, of course, because you rarely access the properties of an AccessObject within an add-in.
Josef
In an add-in (https://github.com/AccessCodeLib/better-access-charts/tree/main/access-add-in ... BetterAccessCharts.accda ) I use CodeProject.AllForms to get the AccessObject of a form in the add-in. The AccessObject is captured correctly.
But when I try to read the properties from it, I get the error -214746725 (Method 'Properties' of object 'AccessObject' failed).
The problem occurs only when the add-in file is opened as an add-in (i.e. when CurrentDb <> CodeDb).
If the add-in file is opened directly, the code runs without errors.
What could be the cause of the error?
Are the properties protected from access from "outside" (not CurrentProject)?
Code from BacChartConfigurationTools.cls
Code:
Public Function GetFormProperty(ByVal FormName As String, ByVal PropertyName As String, _
Optional UseCodeProject As Boolean = False) As BAC_Properties
Dim ao As AccessObject
Dim Prop As AccessObjectProperty
Dim PropJson As String
Dim ChartProperties As BAC_Properties
If UseCodeProject Then ' special: eg start demo form in add-in
Set ao = CodeProject.AllForms(FormName)
Else ' default ... use CurrentProject
Set ao = CurrentProject.AllForms(FormName)
End If
For Each Prop In ao.Properties ' <-- err raised:
' Err.Number = -2147467259,
' Err.Description = "Method 'Properties' of object 'AccessObject' failed"
If Prop.Name = PropertyName Then
PropJson = Trim(Nz(Prop.Value, vbNullString))
Exit For
End If
Next
If Len(PropJson) = 0 Then
Set GetFormProperty = Nothing
Exit Function
End If
With New BAC_JsonConverter
Set ChartProperties = .Json2Properties(PropJson)
End With
Set GetFormProperty = ChartProperties
End Function
/edit:
ao.Isloaded works.
This is a special case, of course, because you rarely access the properties of an AccessObject within an add-in.
Josef
Last edited: