.IncludedMembers...Null, Empty, or what?

R

RayTheOtherRay

I use the following code segment as part of a form button on an Excel
PivotTable generated as Office Web Components on a web page.

//EV_TCNs FieldSet
var fstcns = fa.FieldSets('[EV_TCNs]');
if (fstcns.AllIncludeExclude == 2) //there is filtering
{
var eactcnlevel = 'none';
var eactcnvalue = 'none';
var fldtcn = fstcns.Fields('[EV_TCNs].[TCN]');
if (fldtcn.IncludedMembers != null)
{
x = new VBArray(fldtcn.IncludedMembers);
eactcnlevel = 'tcn'
eactcnvalue = x.getItem(0).UniqueName;
}
var fldcon = fstcns.Fields('[EV_TCNs].[CON]');
if (fldcon.IncludedMembers != null)
{
x = new VBArray(fldcon.IncludedMembers);
eactcnlevel = 'con';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldordertype = fstcns.Fields('[EV_TCNs].[Order Type]');
if (fldordertype.IncludedMembers != null)
{
x = new VBArray(fldordertype.IncludedMembers);
eactcnlevel = 'ordertype';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldreportas = fstcns.Fields('[EV_TCNs].[Report As]');
if (fldreportas.IncludedMembers != null)
{
x = new VBArray(fldreportas.IncludedMembers);
eactcnlevel = 'reportas';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldcontract = fstcns.Fields('[EV_TCNs].[Contract]');
if (fldcontract.IncludedMembers != null)
{
x = new VBArray(fldcontract.IncludedMembers);
eactcnlevel = 'contract';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldshortname = fstcns.Fields('[EV_TCNs].[Short Name]');
if (fldshortname.IncludedMembers != null)
{
x = new VBArray(fldshortname.IncludedMembers);
eactcnlevel = 'shortname';
eactcnvalue = x.getItem(0).UniqueName;
}
setCookie('eactcnlevel', eactcnlevel);
setCookie('eactcnvalue', eactcnvalue);
}

The purpose is to read through the currently filtered values in the
[EV_TCNs] Field Set of the Filter Axis and determine the state of the
user interaction to produce cookies to retain the user preferences when
they next open the page.

If there are no members in the specific .IncludedMembers property,
subscript references to it yeild, "Subscript out of range." I'm using
the condition of "!= null" to avoid this, but am now finding that at
the fldtcn level, it is getting past that condition, but still giving
the "Subscript out of range" message. I don't know how to inspect the
values of the .IncludedMembers array when subscript references cause
error. I'm looking for other ways to determine that there is nothing
there.

Thanks in advance!
Ray <><
 
R

RayTheOtherRay

I'm answering myself for any who may run into this problem and are
searching archives. Another property that I used is the .ubound()
property. It returns the highest index value that is used in the
array. If the array is empty, the return value is -1. Referencing
..ubound does not gag like referencing the first value of an array when
it is non existant.

Thanks!
Ray <><
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top