0

Looking for a way in a MS Access form to remember the field having the focus, switching the focus by code to other fields (requesting entries from the user) and at the end return to the fiels originally having the focus. I tried following code but everything I try to restore focus generates errors:

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
Bughater
  • 53
  • 3
  • 9

1 Answers1

0
Me(hot).SetFocus

or

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

or simply keeping ctl for this:

ctl.SetFocus
Andre
  • 26,751
  • 7
  • 36
  • 80
  • Thanks a lot ! Both ways run perfectly: ctl.SetFocus hot = ctl.Name frm(hot).SetFocus – Bughater Jun 30 '16 at 10:05
  • 1
    If the answer solved your problem, you can [accept it](http://stackoverflow.com/help/someone-answers), this also marks the question as resolved. @Bughater – Andre Jun 30 '16 at 11:11