Screen Object.
You can use the PreviousControl property with the Screen object to determine the control that last received the focus.
The PreviousControl property setting is a String value that is the name of a control.
This property is available only in a macro or Visual Basic and is read-only.
You can’t use the PreviousControl property until more than one control on any form has received the focus after a form is opened. Microsoft Access generates an error if you attempt to access this property when only one control on a form has received the focus.
GotFocus, LostFocus Events.
The following example displays a message if the control that last received the focus was not the txtFinalEntry text box.
Function ProcessData() As Integer
Const conNoPreviousControl = 2483 ' No previous control error.
On Error GoTo Process_Err
If Screen.PreviousControl.Name = "txtFinalEntry" Then
. ' Process Data Here.
.
.
ProcessData = True
Else
' Set Focus to txtFinalEntry and display message.
Me!txtFinalEntry.Setfocus
MsgBox "Please enter a value here for further processing."
ProcessData = False
End If_Bye:
Exit Function_Err:
If Err = conNoPreviousControl Then
Me!txtFinalEntry.Setfocus
MsgBox "Please enter value to process"
ProcessData = False
End If
Resume Process_ByeFunction