Using Sax ActiveX Scripting (long story), I have 3 nested if statements which reuse the same return variable. Script looks roughly like:
Dim rtnArray As Variant
If variable1 <> "" Then
' Perform SQL query against DB2 database
rtnArray = DB2SQLSearch(Query)
If UBound(rtnArray) = 0 Then
' ditto
rtnArray = DB2SQLSearch(Query2)
MsgBox "Gets this far"
If UBound(rtnArray) = 0 Then ' Error!
' Never make it here
What’s odd is that this same code structure is working in a script I wrote last week; I simply changed a couple of the queries and the name of the function (find > replace).
After the 2nd query, I’ve tried a MsgBox CStr(rtnArray(0)(0)) but it yields Error 10025 in : Array has a different number of indexes.
Error codes correspond to the following manual:
http://www.ftgsoftware.com/manuals/basic32.pdf
Figured it out.
In this particular case, the user that I was connecting as had authorization to the first table, but not the second.
This did not throw an error, but there is a message I can check to see whether there was a success or not, so I can look for that and throw my own error, instead of passing back a null array. (it’s not a proper
Null, frankly I’m still not 100% sure what it is, aside from aVariant. But it sure doesn’t likeUBound()!