Msgbox opens TOO quickly

  • Thread starter Thread starter Bonnie
  • Start date Start date
B

Bonnie

Hi there! Using A02 on XP. I have a message boxs that, if
required, is to pop up when the form opens. But my
problem is that it actually appears BEFORE the form opens
and you can't see the form until you click Okay to the
message box. I want the form to open and THEN the message
box to appear. I have tried OnOpen up through OnCurrent
and the msg won't wait for the form to be open underneath.
It is a reminder button that checks to see if a certain
fields date is more than 30 days old and remind you to
update specific data. If they could read the message as
well as see the form, they could better identify what it
is they are to do. If they click okay and then forget the
wordage, Uh-Oh. OnCurrent works for subsequent records but
not the first one. I can't use any edit type procedures as
they may only be looking at the form.

Any help or advice would be very much appreciated. Thanks
in advance for your time!
 
hi,
without seeing any code, i can only guess but it sounds
like a sequence problem. your code triggers the msgbox
before the form. you need to get it the other way around.
 
I have to assume your code check is in the on-open, or on-load event.

And, if the code "stops" in either of those events, the form has not yet
displayed.

The way to do this is to put a public function in the form like:


Public Function MyMsg

if bolShowMsg = false then exit function

if <some cool date calculations> < 30 then
msgbox "your cool message",vbExclamation
endif

end Function

Public Function MyMsgOn

bolShowMsg = True

end function

Also, at the beginning of the form code you need

Option Compare Database
Option Explicit

dim bolShowMsg as Boolean


Now, in your "on-current event", you go:

MyMsg

(in fact, just likely move the code you have in on-current to the public
function MyMsg)

Now, what you do is to open the form you go:


DoCmd.OpenForm "YourForm"

Forms!YourForm.MyMsgOn
Forms!YourForm.MyMsg
 
Back
Top