Clear Global Variable

A

Aaron Reid

I have eight different global variables that make calculations based on
information on the underlying form. I need these variables to empty and
recalcuate (variable1 - varibale2) as the information on the form changes.
My code works as it should but keeps the previous data when doing the new
calculation.

How to I clear all the variables?
 
J

Jeff Boyce

Aaron

I'm confused ...

A "global" variable would be one that is ALWAYS the same ... hence,
"global".

It sounds like you want to compare two values in a specific record (?shown
on a form?). Why not just add a textbox on that form to do the calculation?
Or even easier, do the calculation in a query and use that query to "feed"
the form.

More info, please...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
T

Tokyo Alex

Hi Aaron,

Global variables are available to all procedures in all modules in your
project. Their values are maintained until changed by code, the app stops
running or the project is reset.

To clear them, therefore you will need to do something like:
gstrMyGlobalStringVariable = ""
gintMyGlobalIntegerVariable = 0
......

If you need to clear the variables every time a particular procedure runs
(my understanding of your question), then I think it's likely you don't
really want global variables. Local variables (defined in a certain
procedure) are automatically cleared when the procedure finishes.

Hope this helps,
Alex.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top