Form After Open Event ?

PNGBill

Win10 Office Pro 2016
Local time
Tomorrow, 09:42
Joined
Jul 15, 2008
Messages
2,271
Hi Forum, access 2010 accdb.

I have a question to ask the Operater subject to what data is in a Form Control.

Problem is, if I put the code in the Form Current Event, the question is asked before the form is displayed :eek:

Is there an Event that is "last" like an After Open Event :confused:
 
What is the problem with On Open or On Load?
 
I get the appropriate message from the new form event where it has tested the control source data on a form control.

The message is correct but it displays before the form is able to be seen.
 
Here is one way. There might be better solutions.

Set a module level Boolean variable as as flag when the form opens. Test it with the OnCurrent procedure, ask the question only if it is found and clear the flag.
 
can you clarify

i don't think putting code in the current event displays BEFORE the form is displayed. is that what you meant?
 
Bill wants the form to open than ask a question. But the question appears before the form is displayed when using the On Open Event.

The flag set when the form opens can be tested in the On Current event. The On Current Event first runs when the focus is given to the first record after the form is opened.

Then the flag is cleared to prefent it running on subsequent records.
 
GalaxiomAtHome's method may work... I'd have to think about it.

Another simple method might be to use a Timer

Code:
Private Sub Form_Open(Cancel As Integer)     '[B]or[/B] Sub Form_Load
     Me.TimerInterval = 1 'timerinterval is in milliseconds, but anything > 0 ought to work
End Sub

Sub Form_Timer
     Me.TimerInterval = 0 'shuts off the timer
     msgbox "(your question)"
     '...rest of your code
end sub

Strictly speaking you do not need the Form_Open (or Load) event to set the TimerInterval if you set it (to 1) in design view and save. Setting it in the open or load event helps when debugging-- you won't have to reset the TimerInterval each time you save the form's design after the Form_Timer runs. Obviously we'd also add some error handling to the above.
 

Users who are viewing this thread

Back
Top Bottom