I wrote a custom function to calculate an average. The function uses Public variables.
Query1 has the fields required for the calculation sorted in the correct order. I call the function from Query1 and I get the correct result.
The problem occurs when I create a second query, Query2, that...