Remove focus from all buttons

  • Thread starter Thread starter Francis
  • Start date Start date
F

Francis

Hello

I would like a simple solution to remove focus from all buttons,
restoring the focus on the previous control (consider the previous
control can be inside the subform)
(yes i also toggled all buttons Tab Stop property to No).

Here is what i used:

Option Compare Database

Dim strControlName 'Declare Global Variable

Private Sub Comando162_Click()
On Error GoTo Err_Comando162_Click

strControlName = Screen.PreviousControl.Name

Exit_Comando162_Click:
Exit Sub

Err_Comando162_Click:
MsgBox Err.Description
Resume Exit_Comando162_Click

End Sub

Private Sub Comando162_GotFocus()

Me.Controls(strControlName).SetFocus

End Sub
 
Just put this step in the Click event for the button:

Screen.PreviousControl.SetFocus
 
Back
Top