J
Jon Furman
This is a good one I think...should be ripe for comment and opinion. I wrote
a class that generates a custom form with a variable number of controls and
uses the module.inserttext method to create event handlers and background
code for the form. To be more precise it opens the form in design view,
creates the controls and the code then finally saves, closes the form and
then reopens the form as a subform. This all works brilliantly and I thought
that I was very clever.
Then I ran into a problem....if I do this when I have another form open (one
that has nothing to do the generated form or the form that contains it) and
the unrelated form has it's own variables or static variables in it's
functions then they are reinitialized (ie all numeric variables become 0)
and the code in that form stops running correctly. The code in the class
that's autogenerating the controls is fine and the container form and its
code are fine also. Any other executing form code is toasted though. But
wait....it gets worse. The next time I open the database and then open
effected form, Access crashes. I cannot use the form that was coincidentally
open when the autogenerate was run until I completely delete it and reimport
it from a backup file. Very strange.
Ideally I would like to find a way to keep the variable reinitialization
from happening. I guess that I could write some code to prevent the
autogenerate from running if other forms are open but stopping the problem
from happening in the first place would be a lot better.
I'm on Access 2002 and this is actually an ADP. Anyone else tried to be this
fancy with VBA, gotten burnt like me and found a way around it?
Thanks all, I appreciate any comments that you may have.
Jon
a class that generates a custom form with a variable number of controls and
uses the module.inserttext method to create event handlers and background
code for the form. To be more precise it opens the form in design view,
creates the controls and the code then finally saves, closes the form and
then reopens the form as a subform. This all works brilliantly and I thought
that I was very clever.
Then I ran into a problem....if I do this when I have another form open (one
that has nothing to do the generated form or the form that contains it) and
the unrelated form has it's own variables or static variables in it's
functions then they are reinitialized (ie all numeric variables become 0)
and the code in that form stops running correctly. The code in the class
that's autogenerating the controls is fine and the container form and its
code are fine also. Any other executing form code is toasted though. But
wait....it gets worse. The next time I open the database and then open
effected form, Access crashes. I cannot use the form that was coincidentally
open when the autogenerate was run until I completely delete it and reimport
it from a backup file. Very strange.
Ideally I would like to find a way to keep the variable reinitialization
from happening. I guess that I could write some code to prevent the
autogenerate from running if other forms are open but stopping the problem
from happening in the first place would be a lot better.
I'm on Access 2002 and this is actually an ADP. Anyone else tried to be this
fancy with VBA, gotten burnt like me and found a way around it?
Thanks all, I appreciate any comments that you may have.
Jon