returning control from a modal form to the calling form

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

Guest

I have a Customer form that open a Contact form passing to it an argument.
When the Contact form close I will like to return the control to the Customer form passing a return parameter.
How to do it? Please suggest more then one approach!
Thanks in advance.
 
Paolo said:
I have a Customer form that open a Contact form passing to it an argument.
When the Contact form close I will like to return the control to the
Customer form passing a return parameter.
How to do it? Please suggest more then one approach!
Thanks in advance.

This should happen automatically. What is happening now? You're not
closing the calling form when you open the modal form are you?
 
Rick Brandt said:
Customer form passing a return parameter.

I believe I misinterpreted what you were looking for in my first response.
If you want the equivalent of a MsgBox where your code in the base form
calls the popup box and has its code paused until the popup is responded to
and then you want the code to continue with an additional piece of
information provided by the popup then this is what you can do...

First off, using a modal form is not good enough. While a modal form grabs
focus and won't let go unless you close it, it does NOT cause the calling
code to pause. For that you need to open the popup form using the acDialog
argument of DoCmd.OpenForm. Then to get the information from the popup
back to the calling code you can do one of three things.

1) You can have the popup form push the information into public variables
where the calling code can retrieve it.

2) You can have the popup form push the data into hidden controls on the
calling form where the calling code can access it after the popup is
closed.

3) You can store the data on the popup form and only hide it rather than
close it. Hiding the form will also allow your calling code to continue and
it can then grab the data from the popup form and then close it.

The third option is the one I use. The popup would typically have an [OK]
and a [Cancel] button. [OK] hides the popup and [Cancel] closes it. Then
my calling code can test to see if the popup form is open immediately after
the line of code that opens it. If it is still open I know the user
pressed [OK], otherwise I know they pressed [Cancel].
 
Thank you Rick,
your 3rd solution is very elegant and works fine
It is going to be included in my bag of tricks
--
Paolo


Rick Brandt said:
Rick Brandt said:
Customer form passing a return parameter.

I believe I misinterpreted what you were looking for in my first response.
If you want the equivalent of a MsgBox where your code in the base form
calls the popup box and has its code paused until the popup is responded to
and then you want the code to continue with an additional piece of
information provided by the popup then this is what you can do...

First off, using a modal form is not good enough. While a modal form grabs
focus and won't let go unless you close it, it does NOT cause the calling
code to pause. For that you need to open the popup form using the acDialog
argument of DoCmd.OpenForm. Then to get the information from the popup
back to the calling code you can do one of three things.

1) You can have the popup form push the information into public variables
where the calling code can retrieve it.

2) You can have the popup form push the data into hidden controls on the
calling form where the calling code can access it after the popup is
closed.

3) You can store the data on the popup form and only hide it rather than
close it. Hiding the form will also allow your calling code to continue and
it can then grab the data from the popup form and then close it.

The third option is the one I use. The popup would typically have an [OK]
and a [Cancel] button. [OK] hides the popup and [Cancel] closes it. Then
my calling code can test to see if the popup form is open immediately after
the line of code that opens it. If it is still open I know the user
pressed [OK], otherwise I know they pressed [Cancel].
 
Back
Top