Capturing the value of a parent form in code

  • Thread starter Thread starter TJ
  • Start date Start date
T

TJ

I have a subform that opens up a pop-up form on the click
of a command button. The same subform is on three
different parent forms, and opens the same pop-up
regardless of the parent form. On the close event of the
pop-up form I want to correctly update the subform. Of
course to do this I need to capture the value of the
parent form of the subform and store it in a global
variable so it can be passed on to the pop-up form.

Is anyone aware of a way to capture this value?

Thank you,

T.J.
 
You don't need to use a global variable, and it's probably not a very good
idea to do it this way.

Personally I would open the pop up form in dialog mode (with the acDialog
option in VB). This will pause your code as long as the form stays open and
visible. I'd make the "OK" button (or whatever you use to close the popup
form) hide the form rather than closing it. Then your code can retrieve the
information that you need from the popup form as it will still be open when
the next line runs. If there is a "Cancel" option on the form then get that
to close the form, and add some code to check whether the form is still open
before it tries to retrive the data.

If you don't like that idea, then you could pass the form name in the
OpenArgs property when you open the popup form
 
Back
Top