Gaby,
I think you just found a bug I hadn't actually spotted! So glad I was of some help in a round-about way.
I am not sure why that section is there though, or how it works... That's the explanation I was looking for...?
[Edit] I get it now... It needed to be in the WHERE, and you don't need a DELETE clause at all. 😎 [/Edit]
I have made some, what I think, are improvements to make the whole thing even more useful but I wouldn't want to post that (crediting you of course) without understanding everything about how this works.
Regards,
Gav B.