public variables

  • Thread starter Thread starter Megan via AccessMonster.com
  • Start date Start date
M

Megan via AccessMonster.com

hi.
i have a default year variable defined in a public module.
i get the value from a table on login.
i display the value when i'm in the customer form so i know what year the
prices are for.
if i do i lookup for prices for the default year and none exist, my value
gets erased. or when navigating thru customer records.
i don't understand why.
i'm not re-assigning it anywhere.
any ideas?

i have other public values - for instance, the user's access level, and
that never disappears.

thanks!
 
Hi Megan

It seems strange that one but not all of your public variables should
disappear.

Resetting your code will call ALL public variables to be reset to their
ininitialised values. This can happen if you have an unhandled error which
comes up with the "Debug or End" dialog message. If you click End then your
code will be reset.

Are you sure that is not what is happening?

Otherwise, the only way to change the value of a public variable is to do so
explicitly in code.

Some people prefer to use textboxes on a hidden form instead of public
variables because they do not disappear when VBA is reset, but so long as
your error handling is robust, this should not be necessary.
 
Back
Top