gdanalakshmi
Registered User.
- Local time
- Today, 15:51
- 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???
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???