Hello,
I have a main form with a subform on it. It is essential that the Onload event of the main form is triggered before the Onload event of the subforms form (because the main form creates some class instances that are referred to by different forms that can appear in this subform). Therefore the SourceObject property of the subform should initially be empty, and assigned dynamically. Otherwise the Onload event of the subforms form will be triggered before the Onload event of the main form.
I was glad to have that figured out, but now i am confronted with a very undesirable behavior of MS Access: sometimes it somehow "remembers" the last source object form, and the SourceObject property of the subform mysteriously reappears ... and consequently the order of the Unload events changes, leading to an error caused by refererring to a non-initialized class instance (Run-time error 91: Object variable or With block variable not set)
Trapping the error in each subforms form and then initializing the class there, is not really a desirable solution. I would also have to check if the class was already initialized to prevent initializing it a second time (and losing variable values).
This seems to be (another) weak side-effect feature of MS Acces. Is there someone who understands this problem and can offer me a solution?
I have a main form with a subform on it. It is essential that the Onload event of the main form is triggered before the Onload event of the subforms form (because the main form creates some class instances that are referred to by different forms that can appear in this subform). Therefore the SourceObject property of the subform should initially be empty, and assigned dynamically. Otherwise the Onload event of the subforms form will be triggered before the Onload event of the main form.
I was glad to have that figured out, but now i am confronted with a very undesirable behavior of MS Access: sometimes it somehow "remembers" the last source object form, and the SourceObject property of the subform mysteriously reappears ... and consequently the order of the Unload events changes, leading to an error caused by refererring to a non-initialized class instance (Run-time error 91: Object variable or With block variable not set)
Trapping the error in each subforms form and then initializing the class there, is not really a desirable solution. I would also have to check if the class was already initialized to prevent initializing it a second time (and losing variable values).
This seems to be (another) weak side-effect feature of MS Acces. Is there someone who understands this problem and can offer me a solution?