Pausing Execution of Code In a Form

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

Guest

Hi all

I would like to be able to pause execution of code on a form just after
another form is opened which is designed to collect user input. Once the user
input is collected, the execution of code in the first form is resumed, and
analyses the user input.

So:

1. Code executes
2. User Input Form is opened
3. Code is paused
4. User inputs data into User Input Form
5. Code execution resumes using user data

This is effectively exactly what the MsgBox action does. The difference is
that I want to use a form I have designed myself, rather than a message box.

I guess what is needed is one command to pause execution, and another
command triggered by the User Input Form which resumes the execution again.

Can anyone tell me if this is possible, and if so, how to do it?

Many thanks

David
 
Hi David,

You can open the second form in dialog mode which will pause the code
execution until the dialog form is closed or hidden. In the first form's
code use this to open the second form:

DoCmd.OpenForm "secondFrmName", , , , , acDialog

Once the user input is entered set the second form to visible = false. At
this point the code execution will continue. Add a line at the end of code
in your first form to close your dialog form.

HTH
Steve C
 
That is extremely useful Steve. Thank you.

Steve Conway said:
Hi David,

You can open the second form in dialog mode which will pause the code
execution until the dialog form is closed or hidden. In the first form's
code use this to open the second form:

DoCmd.OpenForm "secondFrmName", , , , , acDialog

Once the user input is entered set the second form to visible = false. At
this point the code execution will continue. Add a line at the end of code
in your first form to close your dialog form.

HTH
Steve C
 
David said:
That is extremely useful Steve. Thank you.


Another useful piece of information is that you can use code
in the form that opens in dialog mode to make it hidden:

Me.Visible = False

that will cause the calling code (that opened the form in
dialog mode) to start executing again. Since the dialog
form is still open you can access values from it and
*then* close the form in the calling code after you get
the values you need.
 
Back
Top