With Event coding requirement

J

Jim Shaw

BlankFormA needs to load FormB and begin listening for raised event from
FormB.
When formB is loaded, I code "...set frmB = Forms!FormB..." to allow
listining to proceed.

When FormB closes, is there anything I need/should do to stop listening in
FormA?

Thanks
Jim
 
M

Michel Walsh

HI,


One object can be "referred" in many places. The object is "closed" only
if no-one referred to it anymore. In your case, when you close FormB, the
object still exists unless you also set your variable frmB to Nothing
(because your variable refer to the form, and your variable is still alive,
that implies FormB will continue to exist because of your variable). A COM
object is not destroy until its "reference count" is zero. When you close
FormB, you just remove ONE of the reference to an object, you don't
(necessary) destroy the object. So, basically, you can try to

Set frmB = Nothing

AND close FormB. If nowhere else you refer to FormB, that may effectively
close FormB (counter example: there is some "pending" code form FormB still
waiting to run).




Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top