That SetFocus thing

J

John

The following code is supposed to check if something was
entered in the Social Security textbox. If the box was
left empty, the user is supposed to get an error message
(this part works) when he attempts to go to the next
control and, after he clicks OK on the message box, the
focus should be set back on the Social Security textbox.
For some reason the Social Security box does not receive
the focus. Can you help?

Private Sub txtSSN_LostFocus()
txtSSN.SetFocus
If Len(txtSSN.Text) = 0 Then
MsgBox "You must enter the client's Social Security Number
(SSN)!", vbExclamation, "Insufficient Data"
txtSSN.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

Similar Threads

SetFocus Thing 1
searh for record. 2
Lost focus event 3
Help with lost focus event 1
Error Message with Duplicate Values 10
SSN Input Mask 1
Type Mismatch in Macro with empty string/null value 7
Forms 3

Top