on_exit Event Procedure

  • Thread starter Thread starter tracktraining
  • Start date Start date
T

tracktraining

Hi Everyone,

I have the following code to message the user to enter in an employee's name
if the user forgot to.

Private Sub txtEmpName_Exit(Cancel As Integer)
If IsNull(Me.txtEmpName) Then
MsgBox "Please Enter Employee Name"
Me.txtEmpName.SetFocus
End If
End Sub

This message appears when I click on the next txt box (leaving txtEmpName
Null). When the message appears and I click "OK", why didn't the cursor go
back to the txtEmpName txt box?

Please help if you can.

Thanks,
TrackTraining
 
Set the focus to another control on the form, then go back to txtEmpName,
like this:

Private Sub txtEmpName_Exit(Cancel As Integer)
If IsNull(Me.txtEmpName) Then
MsgBox "Please Enter Employee Name"
Me.SomeOtherField.SetFocus
Me.txtEmpName.SetFocus
End If
End Sub
 
THANKS!
--
Learning


Nicholas Scarpinato said:
Set the focus to another control on the form, then go back to txtEmpName,
like this:

Private Sub txtEmpName_Exit(Cancel As Integer)
If IsNull(Me.txtEmpName) Then
MsgBox "Please Enter Employee Name"
Me.SomeOtherField.SetFocus
Me.txtEmpName.SetFocus
End If
End Sub
 
Back
Top