Below is the code I want to run only if a particular form "SalesForm" is active.
It works fine, If I leave this form open and work on another forms (It does not switch back to this Form, which means code does not work if it deactive)
But once if I open a report preview screen, it switch back to this form
As per code, the below should only run if the form is active
Why it is getting switch back to this form from report preview
Below is the code I am using on "SalesForm"
Private Sub Form_Timer()
If Screen.ActiveForm.Name = Me.Name Then
DoCmd.Maximize
Me!lblClock.Caption = Format(Now, "dddd, mmm d, yyyy") & Chr(13) & Chr(10) & Format(Now, "hh:mm:ss AMPM")
End If
End Sub
Timer interval is set to 1000
What changes I should do to the code so that it should not switch from report preview to "SalesForm"
Please advice