ACC2000: Limit on ANDs in SQL Select Statement (209761)



The information in this article applies to:

  • Microsoft Access 2000

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.

REFERENCES

For more information about SQL statements and clauses, click Microsoft Access Help on the Help menu, type work with sql in queries, forms, reports, macros, and modules in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MajorLast Reviewed:6/24/2004
Keywords:kberrmsg kbhowto kbinfo kbusage KB209761