Urgent.. Help Me (1 Viewer)

gdanalakshmi

Registered User.
Local time
Today, 16:24
Joined
Nov 26, 2002
Messages
102
I am trying to do a validation for a text box control. I have written code in
Private Sub Last_Name_Exit(Cancel As Integer)

Dim TrimmedStr As String

If Len(Me.Last_Name) > 0 Then

TrimmedStr = Trim(Me.Last_Name)
Me.Last_Name = TrimmedStr

Me.Refresh

If Len(TrimmedStr) > 20 Then

MsgBox "Last Name must be < 20 characters", _
vbExclamation + vbOKOnly, ""

Me.Last_Name.SetFocus

End If
End If

End Sub


But, Me.Last_Name.SetFocus is not working?

Why is it so???
 

AncientOne

Senior Citizen
Local time
Today, 16:24
Joined
Mar 11, 2003
Messages
464
you must set the focus to another field first and then back to the Last_name field.
 

gdanalakshmi

Registered User.
Local time
Today, 16:24
Joined
Nov 26, 2002
Messages
102
Thanks.....
 

Users who are viewing this thread

Top Bottom