Hey all,
I've created a timer-powered "Please Wait" form in Access 2000. I want to be
able to use it whenever I have a process that's going to take some time -
long loops and whatnot.
Here is the code I use -
DoCmd.Hourglass True
DoCmd.OpenForm "frmWait", acNormal
' Big convoluted loop
The form opens (well, at least the caption bar and border do) but it never
fills in so you can't see the message on the "Please Wait" form.
If I open the form as a dialog (modally), then it loads and displays
properly. However, as would be expected, the code on the calling form stops
executing, which kind of defeats the purpose.
I tried seeting the "Pop Up" property of frmWait, but it doesn't seem to
make a difference.
Is there any way that I can have one form loaded in the foreground, while
the code behind another form runs in the background?

Signature
Hmm...they have the Internet on COMPUTERS now!
Wayne Morgan - 21 Jan 2005 14:43 GMT
You could try a Forms!frmWait.SetFocus command to set the focus to the popup
form to force it to paint. Also, try a DoEvents command after opening the
popup form to tell VBA to let other things finish running.

Signature
Wayne Morgan
MS Access MVP
> Hey all,
>
[quoted text clipped - 21 lines]
> Is there any way that I can have one form loaded in the foreground, while
> the code behind another form runs in the background?
MDW - 21 Jan 2005 15:15 GMT
Well, I can get the "Please wait" form to fully display now, but it's acting
as if the Timer isn't firing. I'm sure that isn't true, but I even stuck
"Me.Repaint" in the Timer event.
> You could try a Forms!frmWait.SetFocus command to set the focus to the popup
> form to force it to paint. Also, try a DoEvents command after opening the
[quoted text clipped - 25 lines]
> > Is there any way that I can have one form loaded in the foreground, while
> > the code behind another form runs in the background?
Wayne Morgan - 21 Jan 2005 17:13 GMT
Your looping code is probably taking up all the resources and not letting
the timer event code run. The Access VBA code is not multithreaded. You may
need to add DoEvents somewhere in the middle of your loop to let other items
have a chance to run.

Signature
Wayne Morgan
MS Access MVP
> Well, I can get the "Please wait" form to fully display now, but it's
> acting
[quoted text clipped - 36 lines]
>> > while
>> > the code behind another form runs in the background?
Marshall Barton - 21 Jan 2005 15:26 GMT
>I've created a timer-powered "Please Wait" form in Access 2000. I want to be
>able to use it whenever I have a process that's going to take some time -
[quoted text clipped - 17 lines]
>Is there any way that I can have one form loaded in the foreground, while
>the code behind another form runs in the background?
After the OpenForm line, try using
Forms!frmWait.Repaint
and/or
DoEvents

Signature
Marsh
MVP [MS Access]
MDW - 21 Jan 2005 15:39 GMT
That's similar to Wayne's suggestion. Here's the code now:
DoCmd.Hourglass True
DoCmd.OpenForm "frmWait", acNormal
Forms("frmWait").SetFocus
OPEN_FORMS = DoEvents
Like I indicated on my response to him, the frmWait loads fully now, but it
acts as though the Timer event isn't firing. (BTW, the form as I designed it
has a series of boxes, and it just repetitvely changes the background color
of one from white to red, marching across the form. With the code above, all
the boxes stay white. The "animation" part doesn't occur.)
I think I may be too much of Access. :\
> >I've created a timer-powered "Please Wait" form in Access 2000. I want to be
> >able to use it whenever I have a process that's going to take some time -
[quoted text clipped - 22 lines]
> and/or
> DoEvents
Marshall Barton - 21 Jan 2005 16:55 GMT
You want the wait form to blink?
If so, you might(?) be asking too much. I've always had
trouble getting this kind of form to repaint while some
heavy duty processing is going on in another process. It
may(?) help if you can intersperse a few(?) DoEvents into
the code that's taking all the processor resources as well
as in the timer event. This usually works for me, but there
are times(?) when doesn't.
A Google of Access newsgroups for:
Form repaint progress meter
turned up a couple dozen threads on this issue. There
doesn't seem to be any consensus on how to keep the display
up to date. Some say a DoEvents is adequate, some that a
Repaint is all you need while still others that a Repaint
followed by DoEvents is the only thing that works.
I believe there is a way to do this, I've just never
stumbled across a totally reliable method.
If any one else has something that works reliably, I like to
know about it too.

Signature
Marsh
MVP [MS Access]
>That's similar to Wayne's suggestion. Here's the code now:
>
[quoted text clipped - 37 lines]
>> and/or
>> DoEvents
MDW - 21 Jan 2005 17:03 GMT
The form itself didn't blink, but I had some text boxes whose backgrounds
changed color on the Timer event.
However, I re-wrote the wait form to be more a progressbar type thing, with
a public sub that updates the width of the bar. Then, within the loop itself,
I call that function and then repaint the form. It does exactly what I wanted.
> You want the wait form to blink?
>
[quoted text clipped - 60 lines]
> >> and/or
> >> DoEvents
Marshall Barton - 21 Jan 2005 17:57 GMT
Sounds like the same kind of story everyone else ends up
with. Fiddle with it enough and you get something that
works - at least for a while.
Back to your blinking text boxes. Did you get that to work
before you changed the design? What was the timer interval,
it should be somewhere between 500 and 1000. Anything less
than 500 is too fast.

Signature
Marsh
MVP [MS Access]
>The form itself didn't blink, but I had some text boxes whose backgrounds
>changed color on the Timer event.
[quoted text clipped - 68 lines]
>> >> and/or
>> >> DoEvents
Albert D. Kallal - 21 Jan 2005 22:42 GMT
> OPEN_FORMS = DoEvents
The above needs to be
DoEvents

Signature
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com
http://www.members.shaw.ca/AlbertKallal