On Timer event for form affects other forms ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have coded an On Timer event for a form. It sets the font weight of the
active control to Bold.
My other forms do not have the event and have the timer interval is set to
zero. However once I go to the form with the event, and then to another form,
it also occurs on these other forms. Why? How do I turn this off when going
to another form?

Thanks.
 
I certainly would not expect the type of behaivor you have described. Could
you post the code that you are using in the OnTimer event? Perhaps seeing
the code might shed som light on the subject.
 
Private Sub form_Timer()
On Error Resume Next
If Screen.ActiveControl.Name <> glbACN Then 'If active control <> myACN
do next line
Me(glbACN).FontWeight = 400 'Set myACN to normal font
Screen.ActiveControl.FontWeight = 700 'Set font to Bold
glbACN = Screen.ActiveControl.Name 'Set myACN to active control
name
End If
End Sub
 
I just found that if I execute:
Me.TimerInterval = 0
before opening any other form, the event behaviour does not carry over.
 
The reason it carries over is because you are using Screen.ActiveControl.Name
If you don't want the behavior to carry over, only do it if the form is the
active form
Haven't tested this , but try
If Screen.ActiveForm.Name = Me.Name Then
ok do the font thing
 
Mr B said:
I certainly would not expect the type of behaivor you have described. Could
you post the code that you are using in the OnTimer event? Perhaps seeing
the code might shed som light on the subject.


If you are using Screen.ActiveControl, change it to:

Me.ActiveControl
 
Back
Top