How to Re-set Focus on User Form After Msgbox Closes?

  • Thread starter Thread starter Dave Jenkins
  • Start date Start date
D

Dave Jenkins

Using XP SP3, and Office 2007 SP1.

I have a modeless user form. When one of the buttons on the form fires, I
put up a msgbox. When the msgbox closes, the form has lost focus. This
doesn't seem to affect processing in any significant manner, but it's not
aesthetically pleasing.

Is there any way to keep the focus on the form? Knowing that it will be
lost, is there any way to re-set it?

Thanks.
 
Hi Luc.

Thanks. But that FAQ entry seems to deal with broken file extensions -- is
that what you meant to reference?
 
Hmmm ...

First of all, I misrepresented the problem: As it turns out the form *is*
refocused after a msgbox. However, after the following sequence of code it is
not:

Here's the sequence of events:

Form is loaded.
Form is shown.
Whenever the user clicks a button, the button code sets a flag saying a form
button was clicked and then does some other stuff including selecting a field
in the window.

Then:

reset the buttonclicked flag
beep
do while not buttonclickedflag
do events
wend

When we bust out of this loop, the form is visible, but not focused and the
field in question is selected.

This code continues in a rather small loop, essentially repeating what I've
outlined above.

I'm guessing the select is ultimately what's causing my confusion.
Certainly it will shift focus from the form to the window, and actually -
that's where I want it to be.

So I guess I really don't have a problem at all -- but thanks to both of you
for taking a look at this.

And Steve: "SP2?"
 
Back
Top