On Timer event for form affects other forms ?

M

mscertified

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

Mr B

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

mscertified

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
 
M

mscertified

I just found that if I execute:
Me.TimerInterval = 0
before opening any other form, the event behaviour does not carry over.
 
K

Klatuu

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
 
M

Marshall Barton

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
 

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