MS access vba - How to get message box to popup after form opened

Hi, I would like to have a message display in some cases on a form opening. I open the form from another form - I can get the message to display on Open, current, load events but the popup displays before the form opens so the old form is in the background not the new one.

Does anyone know how to do get it so the form opens then the message displays.

Current code is.
Private Sub Form_Current()
If Me.Status = 1 Then
    MsgBox "Message to Display", vbOKOnly, "Test Popup"
End If
End Sub

Open in new window

donhannamAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
Move the code to the Form_Activate() event.

/gustav
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Depends on how/where/when your hiding the old form.  I would:

1. Hide the calling form before you call the Open for the new form.
2. Put the code in OnOpen or OnLoad event.  If OnOpen, you'll need a Me.Repaint to force the form to draw.

Jim.
Jeffrey CoachmanMIS LiasonCommented:
I'm confused as well.
I see the current event calling a message box, ...but I don't see how you are opening the form. (or hiding the first form?)
...Nor is it clear what form the current event code is on,? (the main form, or the form you are trying to open...?)

In the most basic sense you would open the form, then open the messagebox:
From form1, do something like this:
    DoCmd.OpenForm "Form2"
    MsgBox "Junk"

So here, form1 is open, then the code opens form2 and then the messagebox.
...the message box is then on top of Form 2, (which seems like what you are after...)

To clear things up, can you first explain the need for this functionality?
...or walk us through both user scenarios (step by step)
Something like this:
"I want a user to______________, Then I want___________ to_______."
"But if_____________, then I want_____________to happen"
In a lot of cases, opening a message box (that, in effect, "Pauses" your app), each time a condition is met, might become annoying to users as they must close the message box in order to proceed.

Another alternative might be to display the same "message" in a textbox on either of the forms.
...Or use a form itself as a messagebox (where you have more control things)

JeffCoachman

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

donhannamAuthor Commented:
Thanks Jeff - I never thought of calling the message box from the originating form after I opened the second form - that works perfectly. I was trying to display it from the second form when it opened. I'll try and be clearer in future questions.
donhannamAuthor Commented:
Also /gustav I meant to say I tried on activate - this works but comes up everytime you move from one form to another and back to this form which was not ideal.
Jeffrey CoachmanMIS LiasonCommented:
OK
Glad I could help.
Enjoy your weekend
;-)

Jeff
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.