Not returning to error field

jnh

Registered User.
Local time
Today, 08:47
Joined
Jan 2, 2012
Messages
31
Hi,

Frustration.............

Can anybody tell me why sub listed below will not work - it jumps to next control regardless how many characters are keyed in LastName (won't even give Msgbox if < 10).
Is there a better way to validate keyed Form data ?

Thank you...jnh

Private Sub LastName_BeforeUpdate(Cancel As Integer)

If (Len([LastName] < 10)) Then
MsgBox "zzzzzzzzzzzz" & " " & Len([LastName])
Cancel = True
Me.LastName.SelStart = 0
Me.LastName.SelLength = Len(LastName)
End If

End Sub
 
If Len(Me.LastName.Text) < 10 Then

Bracketting is incorrect and you need to use the Text property because the control is not yet updated.

The reference should also include Me.
 
Try moving the brackets.

If (Len([LastName]) < 10) Then

Untested
 

Users who are viewing this thread

Back
Top Bottom