How display messages from macro after form opens?

  • Thread starter Thread starter Fjordur
  • Start date Start date
F

Fjordur

Hi,
I have a macro that checks fields on a form. The macro issues MsgBox
messages. It is triggered by the "OnCurrent" event of the form, as the doc
says this is the latest event that's triggered when a form is opened.
The problem is, the messages appear BEFORE the form is displayed, making
them difficult to understand. I'd rather they would appear AFTER the form is
displayed so that users can check their data when they see a message.
How should I do that?
 
Fjordur said:
Hi,
I have a macro that checks fields on a form. The macro issues MsgBox
messages. It is triggered by the "OnCurrent" event of the form, as the doc
says this is the latest event that's triggered when a form is opened.
The problem is, the messages appear BEFORE the form is displayed, making
them difficult to understand. I'd rather they would appear AFTER the form
is
displayed so that users can check their data when they see a message.
How should I do that?

Using the current event would cause the message boxes to pop up whilst
navigating between records, surely? Try using the timer event - you could
set the interval to, say, half a second (500) and then set it to zero from
code:

MsgBox "My message.", vbInformation, "Message title"
Me.TimerInterval = 0

HTH - Keith.
www.keithwilby.com
 
Using the current event would cause the message boxes to pop up whilst
navigating between records, surely?
Well, I have a(nother) form that's a list with a VB double click event that
opens a single more detailed form. My checking macro is called on the "on
current" event of the detail form. I want the detail form to display and
then the error messages from the macro to appear. Anything wrong with this
strategy? Are you telling me that there is no event that's triggered AFTER
the form is diplayed? What's the standard way of checking a form when it's
open?
Try using the timer event - you could
set the interval to, say, half a second (500) and then set it to zero from
code
MsgBox "My message.", vbInformation, "Message title"
Me.TimerInterval = 0
Sorry, I understand nothing to this idea. Can you elaborate? What object's
timer event? to do what?
 
Fjordur said:
Sorry, I understand nothing to this idea. Can you elaborate? What object's
timer event? to do what?

Use the form's timer interval and event. In the form's properties box,
change the timer interval from the default value of 0 to 500. In the form's
timer event, put the code you want to execute once the form has opened,
including resetting the interval to 0 (if you don't, then the code will
execute every 500 milliseconds).

Regards,
Keith.
 
Keith Wilby said:
Use the form's timer interval and event. In the form's properties box,
change the timer interval from the default value of 0 to 500. In the form's
timer event, put the code you want to execute once the form has opened,
including resetting the interval to 0 (if you don't, then the code will
execute every 500 milliseconds).
Ah, OK that works. Thanks
 
Back
Top