如何使用变量设置焦点在MS Access表单字段?

时间:2016-06-30 09:50:44

标签: forms variables ms-access setfocus

在MS Access表单中寻找一种方法来记住具有焦点的字段,将焦点按代码切换到其他字段(从用户请求条目),最后返回到最初具有焦点的fiels。我尝试了以下代码,但我尝试恢复焦点的所有内容都会产生错误:

Dim ctl As Control, prp As Property, hot As String, hit As Object
Set ctl = Screen.ActiveControl
hot = ctl.Name
…
hit = "Forms!" & hot
hit.SetFocus

1 个答案:

答案 0 :(得分:0)

Me(hot).SetFocus

Dim hit As Control
Set hit = Me(hot)
hit.SetFocus

或只是保留ctl

ctl.SetFocus