Using a Public Function as Criteria?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
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,
 

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

Back
Top