Return value from modal dialog box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

A button on a form opens a modal dialog box by which the user makes a
selection identifying the subform to load. Other data on the original form
must be passed to the subform, viz. the parent's key (that is not an issue).
I use OpenArgs to send a parameter from the calling routine to the form.
The option group is populated at runtime so the form is reusable; it is
called from a variety of routines. I'm sure that I'm over-complicating the
process. How do I pass the selection (or any value) from the modal form to
the subroutine/form from which the modal form was called?
 
Since the original form is still open, you can create a public property for
the form and set its value, or you can have your modal dialog box update a
text box (visible or hidden, it doesn't matter).

From a subroutine, you could have the modal dialog box update a public
variable or (better) you could create a class, instantiate a public instance
of it and set a property in the class.
 
In the after update event of the control where you make the selection, pass
it back to a text box on your calling form.

Forms!frmCallingForm! txtSelected = Me.SelectionTextBox
 
I have to disagree. I ran a test on it. I created a modal popup form with
one text box and in the after update event of the text box, I passed the
value of the text box back to a text box on the calling form.
 
Klatuu said:
I have to disagree. I ran a test on it. I created a modal popup form with
one text box and in the after update event of the text box, I passed the
value of the text box back to a text box on the calling form.

Sure, not to split hairs here, but the but the user is *also* asking how to
return value(s) to a subroutine also. My approach does not
*necessary* requite you to stuff a value back to a form control.

The user might not want to return a value to a control, but might
want to return values to the calling code.

I quote:
How do I pass the selection (or any value) from the modal form to
the subroutine/form from which the modal form was called?

The above hints that one might want to return values to the subroutine
(both options seem to be left open).

So, sure, you can stuff a value into a control on the form, and your
suggestion
is a good one, and a standard fair. So, I suppose I should not say that you
*must* use a acDialog form, but it is about the only good option when you
want to return values to "code", and not necessary a form.


So, one might want to keep my link and example in mind, as my solution
does NOT requite global vars, and allows you to grab values back from
a form *into* code. This type approach is ideal for date prompt forms etc.
 
Back
Top