Discussion Locked

Call a function in a query

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How do you call a user-defined function in a query? I have a user-defined function that I want to call during a query, can this me done?

4 replies

by timfox2

Yes - It's best to organise such functions in a module and make sure the function is defined as a public funtion. Use the Build button (the ... elipse) in the query design window to help show you the format required.

But be careful. I hope that you are using the user-defined function because Access doesn't already have the function that you require, but just be sure that the function is constructed so that it returns an appropriate string to your query and that posisble error conditions are handled - so that your query doesn't return dodgy recordsets.

by techrep

You call it just like you would any other function. For example:

select * from employees where myuserfunction() = true

This discussion is closed to new replies.