PreviousControl Property Example
The following example displays a message if the control that last received the focus wasn't the txtFinalEntry
text box.
Function ProcessData() As Integer
Dim ctlPrevious As Control
' No previous control error.
Const conNoPreviousControl = 2483
On Error GoTo Process_Err
Set ctlPrevious = Screen.PreviousControl
If ctlPrevious.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."
ProcessData = False
End If
Process_Bye:
Exit Function
Process_Err:
If Err = conNoPreviousControl Then
Me!txtFinalEntry.SetFocus
MsgBox "Please enter a value to process."
ProcessData = False
End If
Resume Process_Bye
End Function