Be aware that the function you supply must be defined in a general module and declared public. (Public doesn't work in class modules - it's a contradiction in terms.)
Also, while this comes up from time to time, you may have limited yourself somewhere in a design. This USUALLY occurs because someone failed to read about parameter queries. (Admittedly, there are times when there is no better workaround than what you just requested.)
Search this forum for the topic "Variables in a query" and combinations of Variable and Query. Pat Hartman posted something on this subject within the last month. If Pat posted it, you can bet on it.