set focus for field just losing focus

set focus for field just losing focus

Post by angi » Wed, 04 Feb 2004 13:40:07


I have a field, txtEID. When a user tabs out of the field, it checks to see if
the employee is eligible for this form. If not, a vbOkOnly message box pops
up. When they press ok, I want the same field to have the focus again. It's
not working. Here's some of what I have in the txtEID_LostFocus event:

Response = MsgBox(Msg1, Style, Title)
If Response = vbOK Then
txtEID.SetFocus
End If
 
 
 

set focus for field just losing focus

Post by Dirk Goldg » Wed, 04 Feb 2004 13:48:32


Use the control's Exit event instead, and just set the event procedure's
Cancel argument to True.

Private Sub txtEID_Exit(Cancel As Integer)

' ...

Response = MsgBox(Msg1, Style, Title)
If Response = vbOK Then
Cancel = True
End If

End Sub

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
 
 

set focus for field just losing focus

Post by angi » Wed, 04 Feb 2004 13:56:40

Dirk,
That worked of course. But how can I clear the name that was in there when it
cancels? Or at least make it so they can start typing a new name (highlight
it).

Thanks!
 
 
 

set focus for field just losing focus

Post by angi » Wed, 04 Feb 2004 15:07:21

I figured it out....thanks for all your help!!!