Like statement

  • Thread starter Thread starter ixniggle
  • Start date Start date
I

ixniggle

I must have a metal block today. I need a Like Operator that will find
fields with just letters of the alphabet and a lenght of 6 or less.

The best I can come up with is:

field Like "[a-z]" OR field Like "[a-z][a-z]" OR field Like
"[a-z][a-z][a-z]" OR field Like "[a-z][a-z][a-z][a-z]" OR field Like
"[a-z][a-z][a-z][a-z][a-z]" OR field Like "[a-z][a-z][a-z][a-z][a-z][a-z]"

There has to be a simpler syntax.
 
FIELD NOT Like "*[!a-z]*" And Len(Field) < 7

Although your formulation may be faster since it doesn't use any vba
function.

Another option would be
FIELD NOT Like "*[!a-z]*" AND
(Field like "?" or Field Like "??" Or ...)

Without testing I think that your solution is probably the quickest.

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
Back
Top