We help IT Professionals succeed at work.

Access 2007 Criteria

CMILLER
CMILLER asked
on
348 Views
Last Modified: 2014-05-14
I have a field in a query that has a long criteria, is there a way to shorten it?

Current Criteria:

Like "13-*T" Or Like "13-*A" Or Like "13-*M" Or Like "13-*B" Or Like "13*F" Or Like "14-*T" Or Like "14-*A" Or Like "14-*M" Or Like "14-*B" Or Like "14*F"

The numbers are the year.
Comment
Watch Question

Project manager
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Dale FyeOwner, Dev-Soln LLC
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2010

Commented:
Rather than use the LIKE or IN operators, which are notoriously slow, I would do something similar to:

WHERE (Left([FieldName],2) = "13" OR Left([FieldName],2) = "14")
AND (Right([FieldName], 1) = "T" OR Right([FieldName], 1) = "A" OR Right([FieldName], 1) = "M" OR Right([FieldName], 1) = "B" OR Right([FieldName], 1) = "F")

Depending on the size of your recordset, this would probably be much more efficient.
CMILLERCyber Security

Author

Commented:
ok, thanks!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.