How to run a code on Timer property only if it is active form

  • Thread starter Thread starter Irshad Alam
  • Start date Start date
I

Irshad Alam

I want to run a code on Form Timer property only if the
form is on focus, I mean on the active screen, therefore ,
I tried the below code but it does not work :

Private Sub Form_Timer()

If Me = Scren.ActiveForm Then
Docmd.Maximze
End If

End Sub

But the above, does not respond, Can any one advise me the
correct code, so that the code will run only when it will
be an activeForm.
 
Irshad,

There are a couple of spelling errors in the code you posted, but I
presume this is just typos in your posting, and you have it correct in
your actual code.

I did not test this, but try...
If Screen.ActiveForm.Name = Me.Name Then

Another possible approach would be to use the form's Activate event to
set its TimerInterval property to the required value, and the Deactivate
event to set the timer interval back to 0.
 
Back
Top