Using a Public Function as Criteria?

L

Lythandra

I have a Public Function that is working just fine and returning back the
correct data as expected.

What I cannot figure out is the syntax to use it as criteria for a query.

Can anyone point me in the right direction?

Thanks
 
M

Michel Walsh

Place it in the criteria line, in the query designer, supplying the required
arguments to that function.

Be sure the function is public and inside a standard module (NOT under a
form, class, or report).

In SQL view, it can be like:

.... WHERE fieldNameToCompareTo = yourVBAfunction( arg1, arg2)



as example, if your function requires two arguments. The arguments could be
field, immediate constant, other function, BUT NOT VBA variable.


Hoping it may help,
Vanderghast, Access MVP
 
L

Lythandra

Thankee Michel

Michel Walsh said:
Place it in the criteria line, in the query designer, supplying the required
arguments to that function.

Be sure the function is public and inside a standard module (NOT under a
form, class, or report).

In SQL view, it can be like:

.... WHERE fieldNameToCompareTo = yourVBAfunction( arg1, arg2)



as example, if your function requires two arguments. The arguments could be
field, immediate constant, other function, BUT NOT VBA variable.


Hoping it may help,
Vanderghast, Access MVP
 
G

George Nicholson

FWIW, even if you don't need to supply any arguments to the function, you
still need to supply the parentheses.
WHERE fieldNameToCompareTo = yourVBAfunction()

HTH,
 
Top