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

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.
 
S

Steve Schapel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top