platedslicer
New member
- Local time
- Today, 19:49
- Joined
- Jan 31, 2012
- Messages
- 5
I need to do a comparison of a complex query and a table, bringing in results from the first in case there are no records in the second to match certain conditions. SQL below.

Eventually I quit being stubborn and used a join with a IS NULL clause to achieve the desired result, but this has me bugged. What could be causing the EXISTS to fail? It's probably something silly, but please be gentle, it's my first time here...
I could swear it was working when I got here after lunch but then it started to complain about an "Invalid Function Argument" (at least, that's what it says in Portuguese). There's no way it's a problem of database size exceeding the 2gb limit (it's under 33mb). I checked all the data types and they matched. A bit of debugging told me the problem was in the first and second conditions inside the first EXISTS, so the JOIN was not responsible. I tried changing aliases around in case I was using reserved keywords. No good. As a last ditch effort I figured maybe the "code" primary key in Table1 was complaining about not being used, so I removed that and indexed the ID field. After that the query began crashing Access whenever it was executedSELECT Q1.* FROM Query1 Q1 WHERE NOT EXISTS (SELECT T1.ID FROM Table1 T1 LEFT JOIN Table2 T2 ON T2.Code = T1.Status WHERE T1.ID = Q1.ID AND T1.FirmID = Q1.FirmID AND T2.Description <> "Finalized");

Eventually I quit being stubborn and used a join with a IS NULL clause to achieve the desired result, but this has me bugged. What could be causing the EXISTS to fail? It's probably something silly, but please be gentle, it's my first time here...