View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Piers 2k Piers 2k is offline
external usenet poster
 
Posts: 11
Default Form, SetFocus and AfterUpdate issue

Hi all,
Small piece of validation on text box. If it's not 8 characters, clear the
text box and place the insertion point in the same text box.
The following in placed in the After_Update event:

Dim PN As String

PN = txtpolicynumber.Text

If Len(Policynumber) < 8 Then
Msgbox "Invalid Entry. Must be 8 digits long", vbOKOnly + vbCritical,
"Data Validation"
txtpolicynumber.Text = ""
txtpolicynumber.SetFocus
End If

This works *ok* in a command button, but *not* in the text box's
after_update event. It places the cursor in the next text box. I can only
assume that it is placing the focus in the required text box, but it is not
cancelling the tab event, and still moving to the next object.

Any ideas on how to cancel the tab? :-s

TIA,

Piers