Pausing a Function while it loads a form.

  • Thread starter Thread starter Amy E. Baggott
  • Start date Start date
A

Amy E. Baggott

I have a procedure that takes a long time to work, and there are periods
where it looks like nothing's happening when the system is in fact very busy.
I have created a form that opens at the beginning of the process with a
field that is changed at each phase to tell the user what phase it's in
(importing tables, updating related tables, checking for errors). the only
problem is that as soon as it starts loading the form, it then goes straight
into the rest of the procedure so that the form does not fully display until
the first breakpoint, which is created by an input box where a subroutine
asks for user input. Is there any way to get Access to wait until the form
has finished painting before it plunges headfirst into the import portion of
the procedure?
 
I have a procedure that takes a long time to work, and there are periods
where it looks like nothing's happening when the system is in fact very busy.
I have created a form that opens at the beginning of the process with a
field that is changed at each phase to tell the user what phase it's in
(importing tables, updating related tables, checking for errors). the only
problem is that as soon as it starts loading the form, it then goes straight
into the rest of the procedure so that the form does not fully display until
the first breakpoint, which is created by an input box where a subroutine
asks for user input. Is there any way to get Access to wait until the form
has finished painting before it plunges headfirst into the import portion of
the procedure?

A DoEvents inserted at the proper place can help:

DoCmd.OpenForm "frmMessage"
For intX = 1 to 20
' Do Something intX here
forms!frmMessage!LabelName.Caption = "Doing something " & intX & "
here"
DoEvents
Next intX

DoCmd.close acForm, "frmMessage"
 
I suspect that you need to add the DoEvents command into your code whenever
you are changing the form. Something like the following two lines

DoCmd.RepaintObject acForm, "FrmProgressMessage"
DoEvents


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
Amy said:
I have a procedure that takes a long time to work, and there are periods
where it looks like nothing's happening when the system is in fact very busy.
I have created a form that opens at the beginning of the process with a
field that is changed at each phase to tell the user what phase it's in
(importing tables, updating related tables, checking for errors). the only
problem is that as soon as it starts loading the form, it then goes straight
into the rest of the procedure so that the form does not fully display until
the first breakpoint, which is created by an input box where a subroutine
asks for user input. Is there any way to get Access to wait until the form
has finished painting before it plunges headfirst into the import portion of
the procedure?


First, try adding one or two DoEvent statements
DoCmd.OpenForm "theform", . . .
DoEvents

If that's not sufficient, then try using the Repaint method.
Forms!theform.Repaint

And maybe a DoEvents after the repaint.

If none of those combinations takes care of it, then I think
you might have to try opening the form in dialog mode. Use
the form's Current event to make itself invisible to drop it
out of dialog mode and make it visible again to redisplay
it.
 
Back
Top