on_exit Event Procedure

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
 
N

Nicholas Scarpinato

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
 
T

tracktraining

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top