A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

MsgBox Displays Too Early



 
 
Thread Tools Display Modes
  #1  
Old October 1st, 2004, 06:59 PM
gdtatuiowa
external usenet poster
 
Posts: n/a
Default MsgBox Displays Too Early

I have a form command button opening another form (leaving the first form
open). In VB code, are setting several object properties at OnOpen of 2nd
form. Last OnOpen VB command is a simply OK msgbox that I want to display
after the second form is visible, but msgbox presents before 2nd form is
seen. Have tried moving msgbox to later form open events but all with same
result -- msgbox displays before 2nd form. 2nd form is very complex, but
cannot simplify form (or don't know how). I can put the msgbox command at
gotfocus event of first data entry field, but I don't want msgbox to display
each time focus moves to 1st field -- only once, when form opens. Must I use
some sort of wait or pause command, to cause msgbox line of code to be
delayed?
  #2  
Old October 1st, 2004, 07:57 PM
Albert D. Kallal
external usenet poster
 
Posts: n/a
Default

To give ms-access a gulp of air, and process the pending keystrokes, and
screen updates, and flush out the event buffer, you can use:

DoEvents.

So, right before the msgbox, put the DoEvents.

However, since the forms on-open event can be canceled, then the form likely
will not yet display. I would suggest you move some, or all of the code to
the forms on-load event, and then put the doevents right before the msgbox.

You might even able to put just the msgbox command in the forms on-load *if*
in fact you are using features of the on open event (the on open event for
example cannot modify any control values).

So, putting the msgbox in the forms on-load should work...and you *might*
need the DoEvents right before the msg box.



--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada

http://www.attcanada.net/~kallal.msn


  #3  
Old October 1st, 2004, 08:09 PM
gdtatuiowa
external usenet poster
 
Posts: n/a
Default

Well, I'm impatient, and managed to cobble something that works using the
TimerInterval property. I set Me.TimerInterval in the OnOpen code and then
added a sub to the On Timer event of the form, to display the msgbox and to
set an unbound, non-visible field that is then used to not execute the msgbox
on successive evocations of the On Timer event. If anyone knows of a better
way to do this, let me know. Thanks.

"gdtatuiowa" wrote:

I have a form command button opening another form (leaving the first form
open). In VB code, are setting several object properties at OnOpen of 2nd
form. Last OnOpen VB command is a simply OK msgbox that I want to display
after the second form is visible, but msgbox presents before 2nd form is
seen. Have tried moving msgbox to later form open events but all with same
result -- msgbox displays before 2nd form. 2nd form is very complex, but
cannot simplify form (or don't know how). I can put the msgbox command at
gotfocus event of first data entry field, but I don't want msgbox to display
each time focus moves to 1st field -- only once, when form opens. Must I use
some sort of wait or pause command, to cause msgbox line of code to be
delayed?

  #4  
Old October 1st, 2004, 08:15 PM
gdtatuiowa
external usenet poster
 
Posts: n/a
Default

Thanks, Albert. My answer was submitted before I saw your reply. I will try
your suggestions. Appreciate the help.

"Albert D. Kallal" wrote:

To give ms-access a gulp of air, and process the pending keystrokes, and
screen updates, and flush out the event buffer, you can use:

DoEvents.

So, right before the msgbox, put the DoEvents.

However, since the forms on-open event can be canceled, then the form likely
will not yet display. I would suggest you move some, or all of the code to
the forms on-load event, and then put the doevents right before the msgbox.

You might even able to put just the msgbox command in the forms on-load *if*
in fact you are using features of the on open event (the on open event for
example cannot modify any control values).

So, putting the msgbox in the forms on-load should work...and you *might*
need the DoEvents right before the msg box.



--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada

http://www.attcanada.net/~kallal.msn



  #5  
Old October 1st, 2004, 08:19 PM
gdtatuiowa
external usenet poster
 
Posts: n/a
Default

And you are right. I am using the OnLoad event to set properties, not the
OnOpen.

"Albert D. Kallal" wrote:

To give ms-access a gulp of air, and process the pending keystrokes, and
screen updates, and flush out the event buffer, you can use:

DoEvents.

So, right before the msgbox, put the DoEvents.

However, since the forms on-open event can be canceled, then the form likely
will not yet display. I would suggest you move some, or all of the code to
the forms on-load event, and then put the doevents right before the msgbox.

You might even able to put just the msgbox command in the forms on-load *if*
in fact you are using features of the on open event (the on open event for
example cannot modify any control values).

So, putting the msgbox in the forms on-load should work...and you *might*
need the DoEvents right before the msg box.



--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada

http://www.attcanada.net/~kallal.msn



  #6  
Old October 1st, 2004, 08:40 PM
Albert D. Kallal
external usenet poster
 
Posts: n/a
Default

"gdtatuiowa" wrote in message
...

And you are right. I am using the OnLoad event to set properties, not the
OnOpen.


Well, hum..I just checked, and my doevents suggestion don't work.

You have to be clear out of the both the on-open, and then the on-load event
before the form can display. So, given that, you need to put the msgbox in a
later event (which we kind of don't have).

My suggestion would be to put the msgbox command after the forms load like:

DoCmd.OpenForm "SecondForm"
msgbox "hello"

If you *must* have the msg box as part of the 2nd form, then put all the
startup code and settings in a PUBLIC function in the form, and go:

DoCmd.OpenForm "SecondForm"
forms("SecondForm").MyFunctionToRun


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada

http://www.attcanada.net/~kallal.msn


  #7  
Old October 1st, 2004, 09:33 PM
gdtatuiowa
external usenet poster
 
Posts: n/a
Default

Hey! Success! Adding the msgbox below the OpenForm command, in the first
form subroutine did the trick.

Thanks again. Very much appreciated.

"Albert D. Kallal" wrote:

"gdtatuiowa" wrote in message
...

And you are right. I am using the OnLoad event to set properties, not the
OnOpen.


Well, hum..I just checked, and my doevents suggestion don't work.

You have to be clear out of the both the on-open, and then the on-load event
before the form can display. So, given that, you need to put the msgbox in a
later event (which we kind of don't have).

My suggestion would be to put the msgbox command after the forms load like:

DoCmd.OpenForm "SecondForm"
msgbox "hello"

If you *must* have the msg box as part of the 2nd form, then put all the
startup code and settings in a PUBLIC function in the form, and go:

DoCmd.OpenForm "SecondForm"
forms("SecondForm").MyFunctionToRun


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada

http://www.attcanada.net/~kallal.msn



  #8  
Old October 1st, 2004, 10:06 PM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default

Or you can use the Current event to run this code, but you'd need to set a
variable that is used to know if the message box has already been shown or
not. Current occurs after the form loads, as well as each time the record
changes, of course.

--

Ken Snell
MS ACCESS MVP

"Albert D. Kallal" wrote in message
...
"gdtatuiowa" wrote in message
...

And you are right. I am using the OnLoad event to set properties, not

the
OnOpen.


Well, hum..I just checked, and my doevents suggestion don't work.

You have to be clear out of the both the on-open, and then the on-load

event
before the form can display. So, given that, you need to put the msgbox in

a
later event (which we kind of don't have).

My suggestion would be to put the msgbox command after the forms load

like:

DoCmd.OpenForm "SecondForm"
msgbox "hello"

If you *must* have the msg box as part of the 2nd form, then put all the
startup code and settings in a PUBLIC function in the form, and go:

DoCmd.OpenForm "SecondForm"
forms("SecondForm").MyFunctionToRun


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada

http://www.attcanada.net/~kallal.msn




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
YES or No Options on a MsgBox using VBA Celtic_Avenger General Discussion 3 September 12th, 2004 07:19 PM
Some subforms going out of sync, others not Michael D. Adams Using Forms 1 August 26th, 2004 02:10 PM
Substituting my own MsgBox for the standard delete confirm MsgBox John S. Ford, MD Using Forms 8 August 20th, 2004 12:05 AM
AUTO_OPEN MSGBOX with button to perminently stop it LB79 General Discussion 1 August 11th, 2004 11:12 AM
MsgBox not displaying Ian Baker Using Forms 6 July 7th, 2004 06:51 AM


All times are GMT +1. The time now is 06:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.