» but the code is over my head.
This doesn't seem to be the case, unless you are not the author of the snippet above. Anyway, I gather that you don't want to change anything in VB, and want to solve this using only query techniques. For this to work, you must only make sure that all temp tables are cleared (emptied) before any selection can be made.
WHERE (Not Exists (Select 1 FROM TempDivision) Or [Common System Name] In (Select Division FROM TempDivision))
I added brackets in case you want to do the same for several fields and temp tables. Please understand that this cannot be optimised easily by Jet. It would be better to produce directly:
WHERE [Common System Name] In ('red', 'green', 'blue')
... or nothing if no selection was made.
Cheers!
(°v°)