Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you clean up your code -- rename your column correlation name 'out' (it's a reserved word), change your keywords to uppercase, etc -- then according to the <a href="http://developer.mimer.com/validator/parser92/" rel="nofollow noreferrer">Mimer SQL-92 validator</a> your SQL is valid Intermediate SQL-92 code. Therefore, you should have a reasonable expectation that this vanilla SQL code would work on any modern SQL implemenation.</p> <p>Sadly, the Access database engine is not a modern SQL implementation and it is not SQL-92 compliant at any level.</p> <p>The problem here is that the Access database engine does not support the <code>CASE</code> expression. Instead, it has a own <code>IIF()</code> expression. Normally I could make excuses by adding the qualifier, "...because the Access database engine shares an expression service with VBA." The thing is, in this case it doesn't: the <code>IIF()</code> expression in Access database engine SQL works differently from the VBA <code>IIF()</code> expression e.g.</p> <pre><code>SELECT IIF(0 = 1, 55 / 0, 99) </code></pre> <p>Works fine, returns the value 99.</p> <pre><code>? IIf(0 = 1, 55 / 0, 99) </code></pre> <p>Fails with 'Division by zero error'.</p> <p>FWIW if you do need VBA and SQL to work the same, consider the <code>SWITCH</code> expression</p> <pre><code>SELECT SWITCH(1 = 1, 55, TRUE, 55 / 0) ? Switch(1 = 1, 55, TRUE, 55 / 0) </code></pre> <p>Both fail with 'Division by zero error'.</p> <p>The Access database engine SQL has expressions not found in VBA (e.g. <code>IS NULL</code>, <code>IN()</code>, etc), so why no <code>CASE</code> expression? We shall probably never know. The Access database engine is poorly documented; specifically, there was never never much to begin with, what we do have is full of errors (material as well as errors of omission) and, because of the engine's age (i.e. old), what documentation exists is gradually disappearing from MSDN and Microsoft's website. The old Jet experts have moved on to other projects.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload