This article was previously published under Q210187
Advanced: Requires expert coding, interoperability, and multiuser skills.
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
View products that this article applies to.
Global myctrname as String
Private Sub form_Timer ()
Dim lngYellow As Long, lngWhite As Long
On Error GoTo Errhandler
lngYellow = RGB(255, 255, 0) 'Set lngYellow variable for
'yellow color.
lngWhite = RGB(255, 255, 255) 'Set lngWhite variable for white
'color.
If Screen.ActiveControl.Name <> myctrname Then ' If active
' control not
' equal to
' myctrname do
' next line.
Me(myctrname).BackColor = lngWhite ' Set myctrname
' variable to white
' BackColor.
Screen.ActiveControl.BackColor = lngYellow ' Set active color
' BackColor to
' yellow.
myctrname = Screen.ActiveControl.Name ' Set myctrname
' variable to
' active control
' name.
End If
Exit Sub
Errhandler:
If Err = 2465 Then ' If error is 2465 which is "Object-defined
' error."
Resume Next ' Resume running on next line after error.
ElseIf Err = 2474 Then ' If error is 2474 which is "No Control is
' active."
Resume Next
Else
MsgBox Err & " " & Error ' Show Error number and string of error
' value.
Exit Sub
End If
End Sub
Keywords: KB210187, kbusage, kbprogramming, kbhowto