Clear Public Variables Upon Query Run

  • Thread starter Thread starter brancazio95
  • Start date Start date
B

brancazio95

I'm using public variables to store cumulative totals that are returned
to a query via a function. For example, the query returns something
like this

Value Total
1 1
2 3

A function is run on each line of data that adds the value from the
current record to the cumulative total in the public variable and
returns the new total from the public variable to the query.

I would like to reset the public variables when the query is run so
that they start from 0. I have not found an easy way to do this. The
only way I've figured out so far is to pass an autonumber to the
function, and when ID = 1, the function contains special logic that
resets the public variables. This solution was fine when I only had
one group of related records in the query, but now I need to handle
multiple groups of related records.

Anyone have any ideas?
 
How are you invoking the query? Simply set the variables to 0 before you do
that.
 
Back
Top