SourceObject property of subform mysteriously reappears

Jurjen

Registered User.
Local time
Today, 18:22
Joined
Oct 26, 2007
Messages
27
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?
 
Sourceobject property of subform mysteriously reappears

>>>undesirable behavior of MS Access: sometimes it somehow "remembers" the last source object form<<<<

I believe "sometimes" is a clue to what's happening. I would guess from my own experience that occasionally you are entering The form design view, and then saving when asked, it will probably ask you if you want to save the subform as well, and if you say yes, then it saves the newly entered record source as well, hard coded in the sub form.

Dear Uncle Gizmo,

Thank you very much for your answer, Yes, it must be something like that, although i could not reproduce it with the scenario that you describe.
I really hope it only occurs in design mode, because otherwise i have a problem ...

with kind regards,
Jurjen
 

Users who are viewing this thread

Back
Top Bottom