R
roger
What’s the difference in these two situations?
First I have a VBA Function that outputs a string I use as a criterion in a
query:
(to simplify
Let’s say the output of funcCrit() is “ABCâ€
Then I have a query with a criterion of :
Like “*â€& funcCrit() & “*â€
That works and finds all the records with 12ABC34 and the like.
But then I wanted a more complex query.
So wrote a different func.
This one outputs a more complex string that INCLUDES the operands and the
quotes:
Let’s say the output of funcComplexCrit() is: Like “*ABC*4*â€
Now I have a query with a criterion of just:
funcComplexCrit()
But that doesn’t work.
I know my function outputs a valid criterion.
If I goto the immediate window and type:
?funcComplexCrit()
I get:
Like “*ABC*4*†(including all the quotes in the right places)
and if I copy and paste that into the query instead of the function call, it
works.
But the function call itself doesn’t.
What have I done wrong?
I tried declaring funcComplexCrit to be a string:
Function funcComplexCrit() as string. (that is “declaring†isn’t it?)
but that didn’t help.
Maybe it should be something else, a variant? An object?
Aha tia
First I have a VBA Function that outputs a string I use as a criterion in a
query:
(to simplify
Let’s say the output of funcCrit() is “ABCâ€
Then I have a query with a criterion of :
Like “*â€& funcCrit() & “*â€
That works and finds all the records with 12ABC34 and the like.
But then I wanted a more complex query.
So wrote a different func.
This one outputs a more complex string that INCLUDES the operands and the
quotes:
Let’s say the output of funcComplexCrit() is: Like “*ABC*4*â€
Now I have a query with a criterion of just:
funcComplexCrit()
But that doesn’t work.
I know my function outputs a valid criterion.
If I goto the immediate window and type:
?funcComplexCrit()
I get:
Like “*ABC*4*†(including all the quotes in the right places)
and if I copy and paste that into the query instead of the function call, it
works.
But the function call itself doesn’t.
What have I done wrong?
I tried declaring funcComplexCrit to be a string:
Function funcComplexCrit() as string. (that is “declaring†isn’t it?)
but that didn’t help.
Maybe it should be something else, a variant? An object?
Aha tia