Semi-modal form?

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

Guest

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?
 
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.
 
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.
 
MDW said:
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?


After the OpenForm line, try using
Forms!frmWait.Repaint
and/or
DoEvents
 
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. :\
 
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.
 
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.

Marshall Barton said:
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.
--
Marsh
MVP [MS Access]


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. :\
 
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.
 
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.
 
Back
Top