mscertified said:
I need to test if a control has the focus, is it possible?
The reason I need to know is I am setting focus on a mousemove event
and I only want to do it once otherwise I get flicker.
Two ways I can think of:
1. Set a module-level flag variable when the control gets the focus (in
the GotFocus event), and reset it in the LostFocus event.
2. Check to see if this is the active control:
'----- warning: air code -----
Dim ctlActive As Access.Control
Dim blnMyFieldHasFocus As Boolean
On Error Resume Next
Set ctl = Me.ActiveControl
If Not (ctl Is Nothing) Then
If ctl Is Me!MyField Then
blnMyFieldHasFocus = True
End If
End If
If blnMyFieldHasFocus Then
' MyField has the focus
Else
' It doesn't.
End If
'----- end code -----