View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Form, SetFocus and AfterUpdate issue

"harpscardiff"

is this starting to sound repetitious. Same advice you received yesterday.


--
Regards,
Tom Ogilvy


"Leith Ross" wrote
in message ...

Hello Piers 2k,

You need to place the macro in the Exit event and use Cancel. You can
copy and paste the updated macro into your project.


Code:
--------------------
Private Sub txtPolicynumber_Exit(ByVal Cancel As

MSForms.ReturnBoolean)

L = Len(txtPolicynumber.Text)

If L 0 And L < 8 Then
Msgbox "Invalid Entry. Must be 8 digits long", vbOKOnly + vbCritical,

"Data Validation"
Cancel = True
With txtPolicynumber
.SelStart = 0
.SelLength = L
.SetFocus
End With
End If

End Sub

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=483052