Search code examples
ms-accessms-access-2007jet-sql

"Expression is typed incorrectly, or it is too complex" error - Access 2007


As the question says, I get this error whenever I try to run my query.

I have 3 fields I want to search in each table, an OEM code, models and additional search terms.

Here is the SQL:

PARAMETERS [Search] Text ( 255 );
SELECT *
FROM inkSearch
WHERE inkSearch.[OEMCode] & inkSearch.[printers] & inkSearch.[ast] LIKE "*" & [Search] & "*"
UNION SELECT *
FROM tonerSearch
WHERE tonerSearch.[OEM Code] & tonerSearch.[Models] & tonerSearch.[Additional Search Terms] LIKE "*" & [Search] & "*";

The error goes away if I remove the LASERS.[Models] field, however this is no different to the inks printers field and I can see no reason this is giving me problems.


Solution

  • I have changed the query to this which seems to work. I had initially based it off two queries that narrowed down the fields.

    I also discovered that the Models field was text on the toner table and memo on the inks which may have caused it.

    The below query appears to have fixed this issue:

    PARAMETERS [Search] Text ( 255 );
    SELECT LASERS.[OEM], LASERS.[T1inclSell], LASERS.[Yield], LASERS.[Models], LASERS.[AST]
    FROM LASERS
    WHERE (LASERS.[OEM] & LASERS.[Models] & LASERS.[AST]) Like "*" & [Search] & "*"
    UNION ALL SELECT INKS.[OEM], INKS.[T1inclSell], INKS.[Yield], INKS.[Models], INKS.[AST]
    FROM INKS
    WHERE (INKS.[OEM] & INKS.[Models] & INKS.[AST]) Like "*" & [Search] & "*";