You could do this with an outer join.
I wish you had shown your main query. As it is, I'll have to just use a sample:
Code:
SELECT T1.custID, T1.sum1, T2.sum2,
(T1.sum1-T2.sum2)/T2.sum2 AS pct.
IIF( C.SumDiff IS NULL, 'No', 'Yes' ) AS isPercentageBigEnough
FROM ( table1 AS T1 INNER JOIN table2 AS T2 ON T1.custid = T2.custid )
LEFT JOIN Constants AS C ON ( (T1.sum1-T2.sum2)/T2.sum2 ) >= C.SumDiff
This assumes that there is only one row in the Constants table. And you put each contant into its own field.
If, instead, the Constants table has only two fields (ConstantName, ConstantValue say) then we'd need a variation on that. Incidentally, I really think that such a table with only the two fields is a superior design. It allows you to add new constants at any time without needing to restructure the DB. The only thing I might do is have 3 fields: ConstantName, ConstantNumber, ConstantString. Where each ConstantName has a value in *EITHER* (but not both) ConstantNumber and ConstantString. And use DOUBLE for the ConstantNumber. It can always be compared to any other numeric type without need for conversion.
Oh, what the heck. Here's what the query would look like if you used my concept of a 3-column Constants table:
Code:
SELECT T1.custID, T1.sum1, T2.sum2,
(T1.sum1-T2.sum2)/T2.sum2 AS pct.
IIF( C.SumDiff IS NULL, 'No', 'Yes' ) AS isPercentageBigEnough
FROM ( table1 AS T1 INNER JOIN table2 AS T2 ON T1.custid = T2.custid )
LEFT JOIN Constants AS C
ON ( C.ConstantName = 'SumDiff' AND ( (T1.sum1-T2.sum2)/T2.sum2 ) >= C.ConstantNumber )
The extra parens in the ON clause for the LEFT JOIN *are* necessary, but if you store this as a query in Access and then retrieve it, Access will have lost the parens. It's a bug I reported in Access98, Access2000, and Access2003. Dunno if it got fixed in more recent versions.