Ubound does not work

I may have misunderstood something. +1? In reference to what?
In response to that link I posted. It was almost as you offered, but with +1 added
 
As The_Doc_Man Said you should use Ubound(HLforInvoice,2)

Your SQL "SELECT HorseID FROM tbHorse WHERE Mark=-1;" will return an array a(0, n) 0 because there is one field in the recordset n is the number row in the recordset.
 
In response to that link I posted. It was almost as you offered, but with +1 added

No, I didn't miss that point and didn't intend to modify the answer. The point is, why would the OP get 0? And the answer is because he might have been querying the wrong subscript in a two-subscript array. The "+1" would hide the zero and thus gloss over the point being suggested.
 
No, I didn't miss that point and didn't intend to modify the answer. The point is, why would the OP get 0? And the answer is because he might have been querying the wrong subscript in a two-subscript array. The "+1" would hide the zero and thus gloss over the point being suggested.
I think it's normal to get 0 because the first dimension of the array contains the fields of the recordset and in his query only one field retrieved the subscript is 0 (zero-based), if there are two fields the Ubound will return 1.
 
Yep, you have a two dim array created from "SELECT HorseID FROM tbHorse WHERE ... " etc
So the array has:
dimension 1=Fields (there is 1 field, HorseID, so the ubound for that dimension is 0)
dimension 2=Rows (there are .recordcount rows, so the ubound for that dimension is recordcount - 1)

The upper bound for dimension 1 is Ubound(arrayname, 1) or just Ubound(arrayname)
The upper bound for dimension 2 is Ubound(arrayname, 2)

So you have no problem, just do what Docman said and check the second dimension instead of the first.

Jack
 

Users who are viewing this thread

Back
Top Bottom