striker
04-11-2002, 01:34 AM
This is driving me crazy. I have declared my variables as public within a module which contains a some functions.
I am then using some of the variables from a form procedure. The variables which are referenced from the form have all lost their contents when i need to use them in the module functions. Has anyone got any ideas on how to stop this or get round it.
Put them on a hidden form which remains open for as long as you need.
striker
04-11-2002, 02:31 AM
Thanks for that, but, the form which the buttons are on which fills the variables is still open, I can't see that putting the variables on a hidden form is any different. I will however try it. You may detect from the tone that I am slowly losing the will to live.
I see this "I have declared my variables as public within a module which contains a some functions."
I usually use a separate module something like
Option Compare Database
Option Explicit
Public MyName As String
Public MyVal As Integer
Public MyTest As String
Public MyAmount As Currency
Public MyValue As Currency
Public MyID As Integer
but check your functions for any errors will cause them to lose their value.
HTH
Pat Hartman
04-11-2002, 04:05 PM
There seems to be certain situations where Access can "loose" the values of global variables. I'm sure that it's a bug but I haven't been able to pin down exactly why this happens. I have run into the problem primarily during development. The loss usually occurs when there is a runtime error.
Anyway, it was annoying enough that I needed to do something about it so I changed to using a hidden form to store the variables and the problem disappeared.