I bypassed all that or else I won't have been able to get to your modules and queries. I was on frmReport when I asked.when the db loads enter andy for username and andy for password
click the auditing button on the home page
There's nothing wrong with the function. How do you expect a median when your actual query is doing lots of Avg, Min and Max, whereas the sql statement in the function doesn't have any of that?