1

I've seen answers to questions similar to this one, but I haven't been able to find anything that addresses this exact situation.

Goal: Populate a list box and/or a worksheet with the output of a HypQueryMembers function. For example, I would like to get a list of the descendants of account 10100 without having to perform an ad hoc query and zoom in. I know how to get the return code, e.g. 0 if successful, but I want the actual output. I found some code that populated a list box, but I haven't been able to get it to work for me. I receive the error "Could not set the List property. Invalid property array index." My code follows:

Sub TestQueryMbrs()

Dim X As Integer
Dim arrAccounts

X = HypQueryMembers(Empty, "10100", HYP_DESCENDANTS, Empty, Empty, Empty, Empty, arrAccounts)

If X <> 0 Then
    MsgBox "Unable to populate members." & vbCr & vbCr & "Error: " & X, vbCritical + vbOKOnly
Else
    UserForm2.ListBox1.List = arrAccounts
    UserForm2.Show
End If

End Sub

Any idea what I'm doing wrong? Also, I would like to accomplish the same thing, but populate a worksheet rather than a list box. But one step at a time!

Thanks!

4

2 回答 2

0

我今天遇到了同样的问题并遇到了这篇文章 - 我意识到它已经有多年历史了......

Oracle 关于这个功能的文档有点混乱......至少他们在页面底部使用的示例:https ://docs.oracle.com/cd/E72988_01/DGSMV/ch12s15.html

例如,您需要输入integerHYP_DESCENDANTS 的值,而2不是代码中显示的文本。

下面是一个很好的代码片段来验证你的数组:

Declare PtrSafe Function HypQueryMembers Lib "HsAddin" (ByVal vtSheetName As Variant, ByVal vtMemberName As Variant, ByVal vtPredicate As Variant, ByVal vtOption As Variant, ByVal vtDimensionName As Variant, ByVal vtInput1 As Variant, ByVal vtInput2 As Variant, ByRef vtMemberArray As Variant) As Long
Sub Example_HypQueryMembers()

sts = HypQueryMembers("INSERT WORKSHEET NAME HERE", "INSERT SMARTVIEW MEMBER HERE", 1, Empty, Empty, Empty, Empty, vArray)

If IsArray(vArray) Then
  cbItems = UBound(vArray) + 1
      MsgBox ("Number of elements = " + Str(cbItems))
   For i = 0 To UBound(vArray)
      MsgBox ("Member = " + vArray(i))
   Next
Else
   MsgBox ("Return Value = " + Str(vArray))
End If

End Sub
于 2019-06-13T15:42:28.367 回答
0

10100是该字段的真实名称吗?我怀疑您将其称为帐户,应该将 10100 替换为帐户,因为该参数似乎仅限于字段名称而不是单个成员。但是,我尚未确定如何获取特定帐户/成本中心的后代,因此您的方式可能是正确的方法。

我建议尝试将更改仅更改为“帐户”,然后尝试将变体添加到 Dim arrAccounts,然后如果这不起作用,则完全删除 Dim arrAccounts。

在显示 Userform2 之前,您可能还无法填充列表框?您可以将 application.screenupdating =FALSE 然后 TRUE 包装在 Userform2 更改周围,这样如果存在滞后,用户就不会看到正在填充的列表框。

于 2018-04-25T07:40:05.430 回答