Yes, really - that is what I am complaining about. It's not the amount of effort to necessary to get this working, it's the fact that ANY effort is necessary at all. Local variables are supposed to get destroyed when their containing form closes, period. Stuff is supposed to work the way the manuals say it works. I should not have to deal with inventing workarounds for random bugs because the guys as MS can't be bothered to test their stuff properly.Really? This is what we are complaining about. I mean come on. If I had 50 forms I figure I could do this manually for all forms in less than 5-10 minutes. I am sure far quicker than for you to write the post. If I had 10,000 forms I could write code in extensibility to do this.
1. Check if Close form method exists
2. If not add a close form method
3. Add code to set the event raiser to nothing
I assume in form you use the same variable to hold the event raiser instance.
What if it was numeric variables, instead of a WithEvents class variable? Or string variables? Or string variables beginning with a certain letter? Or arrays? Or only two-dimensional arrays, but one dimension or greater than two worked okay? Sure - easy to set them all to zero, nothing, empty or whatever on exit - if you know they have that problem, and if you remember it every time. But would you also think it was fine, because it was 'easy' to fix?
Yes, I do use the same name in every form. And my standardizing all these forms to be as identical as possible made it simple to put together a three-line sub with the single action of setting the WithEvents variable to Nothing and slap it into every code module. Grand total of maybe 15 seconds to write the sub and 30 seconds to install it everywhere, compile and save, once I realized what I needed to do. Not the point - the point is that I should not have to do this. This is a bug in the VBA runtime system, and it is not a trivial one, even if the workaround for it is.