how to test if a particular control has focus?

后端 未结 2 1478
春和景丽
春和景丽 2021-01-19 05:07

i have access 2007 form and i want to test if a particular control (toggle button) has the focus ,

something like :

if gotfocus(mytoggle) then
dosom         


        
相关标签:
2条回答
  • 2021-01-19 05:31

    This for the current form:

    If (mytoggle Is Me.ActiveControl) Then
    

    This for the current Access.Application:

    If (mytoggle Is Screen.ActiveControl) Then
    

    Be careful, if no control has focus, *.ActiveControl may not exist.

    0 讨论(0)
  • 2021-01-19 05:36

    Unfortunately, there are situations where the .ActiveControl is temporary non-existing ! When records are scrolled in a form, the procedure Form_Current() gets run. Already at the beginning, there is no focus anymore – the focus is reset to the previous field only after Form_Current() has terminated.

    0 讨论(0)
提交回复
热议问题