MsgBox after Form_Current

jaydwest

JayW
Local time
Today, 06:02
Joined
Apr 22, 2003
Messages
340
This seems like a dumb question but for the life of me, I cannot figure out how to do it.

I want to display a message box when a form is opened and displayed based on some test done in the Form_Current Event. However all the code in the Form_Current event is fired off before the form is displayed. But I want the form to be displayed first.

The MsgBox is modal so the form isn't displayed until I click the OK Button on the msgbox.

How can I display the form first and then display the MsgBox?

Thanks in advance for your help! :cool:
 
AFTER FURTHER RESEARCH HERE'S WHAT I FOUND

1. You cannot use any code on the Form_Current event because it is always executed before the form is displayed.

2. I created a public function on the form to be opened that tested some fields on the form and if the test was positive, display a msgbox.

3. On the Calling form, i.e. the form on which the OpenForm button is located, and in the Sub that opens the Form, I added a line after the OpenForm Command to call the public Function on the form that is opened.

The form open command runs through completion and displays the form. Then the public function is called and the MsgBox appears over the form and it has the focus.

ANY BETTER WAYS OF DOING THIS WOULD BE GREATLY APPRECIATED.
 
Hello Jay,

If I'm following you, I would think one idea, is to put an unbound text box on your form, set the width and height to 0" so it doesn't show on your form, set TabStop and Enabled to "No" then have the form set the focus to it, after it opens. Then you could put your Msgbox criteria code and Msgbox code in the OnFocus event of this text box.

Just a thought!,
Shane

P.S. You and I posted at the same time. Don't know that this is a better idea, but it's idea, so I'll leave it.
 
Shane,

Good suggestion but surprisingly the Control.OnFocus and Control.Enter events both fire off before the form is displayed.

Thanks for the suggestion

I just can't help but think there is some easier way to do this than my function call.
 

Users who are viewing this thread

Back
Top Bottom