Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get VBA code to pause until another activity is complete? 2

Status
Not open for further replies.

Paul7905

MIS
Jun 29, 2000
205
US
I have a question regarding getting VBA code to pause or wait for another process to complete.

Here is my dilema:

I have a form (let's call it Form1) with a command button on it which runs some VBA code in the on the click event.

In the middle of this code, I may determine that it is necessary to open another form (Form2) so that the user can enter some data to create a new record.

I need a way, in the Form1 code, to wait for the activity in Form2 to complete and then resume the code.

In other words, when the code in Form1 determines it needs to open Form2, it can open Form2 and then monitor whether Form2 is open and when it determines Form2 is closed, the Form1 code will resume where it left off.


I thought of using the forms timer as a solution but it will not work unless I can somehow in the Form1 code do some sort of check every X seconds to see if Form2 is open or not and then Resume processing when it determines Form2 has been closed by the User.

Has anyone had to do something similar and have a solution?

Thanks !

Paul
 
Hi Paul!

Try this:

DoCmd.OpenForm "YourForm", , , , , acDialog

The acDialog is called the windowmode, in this case you are telling Access that the form you are opening must be closed before you continue to run the code in the calling form.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Thanks Jeff ! Just tried it and it works perfectly !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top