suspending execution of code until control is returned

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

I am trying to execute VB code that opens a form,
manipulates the text entered in the form and then
continues to the next various commands. My problem is
that the execution continues once the form is open. My VB
skills leave to desire and I want to know if I can do
this in one step using a "hold-on until I am done with my
screen" type command/switch or if I have to do it in two
individual functions?
 
Frank,

The following code will stop execution after the form opens and resume when the
form either becomes not visible or is closed:

DoCmd.OpenForm "NameOfForm",,,,,acDialog
<The code from here to the end will not execute until
the form becomes not visible or is clsed>
 
Would adding a DoEvents to your code help

My understanding of this is that the next piece of code wont execute until
the previous line of code has finished.

If I am wrong can someone please put me right

HTH
 
Newbie said:
Would adding a DoEvents to your code help

My understanding of this is that the next piece of code wont execute until
the previous line of code has finished.

If I am wrong can someone please put me right

DoEvents relinquishes control to the operating system, not to another
process within Access. It is entirely possible that the tasks pending in the
Operating System, may indeed be the VBA code, but you have no way of
ensuring that.

You are correct in the assumption that VB/VBA code executes sequentially,
but sometimes it can execute asynchronously, especially if you are using
named queries within the code. Moving some of the code to another
sub-routine can often force it to execute in the manner you wish, although
that is rarely necessary. Using the modal methods described is usually the
best solution.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top