how to test if a particular control has focus?

大憨熊 提交于 2019-12-01 20:58:35

问题


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
dosomething
endif

or maybe like :

if me.mytoggle.setfocus = true then
dosomething
endif

I have searched and cannot find this , can someone tell me what is correct top to do this ?


回答1:


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.



来源:https://stackoverflow.com/questions/20373426/how-to-test-if-a-particular-control-has-focus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!