P
Paul James
I'm trying to use the same static variable in two different form modules -
one being the main form and the other its subform.
I'm using this variable to set the value of a subtotal control in the main
form, that functions as a sort of calculator. As the user checks or
unchecks a Paid field in the subform datasheet, that subtotal displays the
sum of the Paid records. So I need the static variable to remember it's
value between procedure calls. However, I also need it to respond to events
in the main form. For example, when the user clicks a certain control on
the main form, it unchecks all the Paid fields in the subform, and it needs
to reset the static variable to zero. The same variable is also used in the
Form_Current event of th main form.
This variable seems to be working for the most part, but I've noticed that
under certain conditions the variable doesn't get properly reset. I think
it may just be a flaw in my programming logic, and I'm trying to track it
down. But I'm also wondering if it could be a problem with the way I've
defined the static variable. Here's what I've done:
In the standard Module1 I have the Dimension statement
Public subTotal
(The compiler produces an error if you try using Static subTotal in the
definition area of Module1).
In each of the procedures in the form modules that use the subTotal
variable, I include the statement
Static subTotal
My question is this: is this a legitimate way to define a static variable
that's used by procedures in two different form modules? Or do I need to
modify my variable definitions?
Thanks in advance,
Paul
one being the main form and the other its subform.
I'm using this variable to set the value of a subtotal control in the main
form, that functions as a sort of calculator. As the user checks or
unchecks a Paid field in the subform datasheet, that subtotal displays the
sum of the Paid records. So I need the static variable to remember it's
value between procedure calls. However, I also need it to respond to events
in the main form. For example, when the user clicks a certain control on
the main form, it unchecks all the Paid fields in the subform, and it needs
to reset the static variable to zero. The same variable is also used in the
Form_Current event of th main form.
This variable seems to be working for the most part, but I've noticed that
under certain conditions the variable doesn't get properly reset. I think
it may just be a flaw in my programming logic, and I'm trying to track it
down. But I'm also wondering if it could be a problem with the way I've
defined the static variable. Here's what I've done:
In the standard Module1 I have the Dimension statement
Public subTotal
(The compiler produces an error if you try using Static subTotal in the
definition area of Module1).
In each of the procedures in the form modules that use the subTotal
variable, I include the statement
Static subTotal
My question is this: is this a legitimate way to define a static variable
that's used by procedures in two different form modules? Or do I need to
modify my variable definitions?
Thanks in advance,
Paul