Microsoft KB Archive/209761

= ACC2000: Limit on ANDs in SQL Select Statement =

Article ID: 209761

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209761



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).



SUMMARY
There is an undocumented limit on the number of ANDs that you can use in an SQL Select statement. The limit is 99 ANDs in a WHERE clause and 99 ANDs in a HAVING clause.

Microsoft Access 2000 returns the following error messages when you exceed this limit:

Expression too complex

-or-

Query is too complex.

The error can also occur if the query includes a Switch function expression that contains more than 13 argument sets. The workaround is to create a user-defined function (UDF) incorporating a Select Case statement, and calling the UDF from the query.

