Not exactly sure what you want to do. In order for a module to return a function you need to declare it in the function line. For example:
Function TEST()as integer
'...your code
'place at end of code
TEST = 9
end function
This function will return 9. In the criteria section of your query you need to call the function. Example: TEST()