The LIKE operator

sparx

Morphed Human
Local time
Today, 06:28
Joined
Jul 22, 2002
Messages
80
I am trying to validate a field in a text box to allow only characters/letters and nothing else....I tried using the like operator..eg myVar LIKE "[A-z]" but this works for only one character.... and "*[A-z]*" is not valid either...
Any held would be greatly appreciated

Thanks in advance,

Erik
 
If you are doing it with the form's validation rule then this is what you would put.

Like "[A-z]"

If you are doing it with code, do it in the textbox's Before Update event like this:

Code:
Private Sub Text5_BeforeUpdate(Cancel As Integer)
    If Text5 Like "[A-z]" = False Then
        MsgBox "Illegal entry"
        Cancel = True
        Text5.Undo
    End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom