I have some variables that I set in the Open Event of a sub-form of my Main Form. I use these in the Current Event of the sub-form.
The first time the Main Form is loaded, the Open Event of the sub-form is triggered and the variables are set. I have checked these are set correctly.
However, the second time the Current Event is triggered, these variables have been reset to zero (they are only ever set in the Open Event).
I have got round this by moving the variables to a Module and making them global.
It seems to me that once the Sub-form has been loaded from the Main Form, any variables set at the top of the Sub-Form (i.e. after the Option Explicit) are all reset to zero.
Its as if the sub-form is being closed and just left as part of the main form - which would of course mean any variables set in the Open Event would lose their value.
I have read that any untrapped error may set variables to zero, but the code seems to work without any errors being apparent.
Can anyone confirm my suppositions about variables declared at the top of sub-forms.