M
Mike S. S.
When running a crosstab query, one cannot tell ahead of time what columns are
going to appear based on parameter criteria fed to an underlying query that a
crosstab query is created from. That, of course, is the dynamic nature of
crosstab result sets. However, if I know all the possible values for the
columns because the field the column is based on has a finite number of
possible values, how can I test if a particular column is present using VBA?
With the usual construct of rs![X], where X is one of the possible column
values, if that value does not appear when the crosstab is run, a debug of
that if statement will show the error message that "item not found in this
collection". MY QUESTION IS:
how can I error trap for this? That is, if I want to test for rs![X].value
and it does not exist, then the code just skips by if on error resume is
used; otherwise the cdoe breaks. I would ideally like to have another IF
statement outside of the one above that checks for the existance of that
column, and I do not know how to do this. Is there an error code associated
with "item not found in this collection" that I can look for? If so, what
function would I use to test for the error condition and what value would it
need to equal for ""item not found in this collection"???? And if this is
not a possible or best approach, how should I detect/look for a particular
column in a crosstab query when the query is run in code and the recordset is
processed in code looking for a specific resulting column and its value???
Thanks to anyone who can help me!!!!
Mike S.
going to appear based on parameter criteria fed to an underlying query that a
crosstab query is created from. That, of course, is the dynamic nature of
crosstab result sets. However, if I know all the possible values for the
columns because the field the column is based on has a finite number of
possible values, how can I test if a particular column is present using VBA?
With the usual construct of rs![X], where X is one of the possible column
values, if that value does not appear when the crosstab is run, a debug of
that if statement will show the error message that "item not found in this
collection". MY QUESTION IS:
how can I error trap for this? That is, if I want to test for rs![X].value
and it does not exist, then the code just skips by if on error resume is
used; otherwise the cdoe breaks. I would ideally like to have another IF
statement outside of the one above that checks for the existance of that
column, and I do not know how to do this. Is there an error code associated
with "item not found in this collection" that I can look for? If so, what
function would I use to test for the error condition and what value would it
need to equal for ""item not found in this collection"???? And if this is
not a possible or best approach, how should I detect/look for a particular
column in a crosstab query when the query is run in code and the recordset is
processed in code looking for a specific resulting column and its value???
Thanks to anyone who can help me!!!!
Mike S.