Nested IIf's are often ugly. 4 of them are down right hideous and I'm not even going to try to figure that one out! The obvious issue is that you can't subtract from Null or an empty string. The not so obvious is why you've taken this approach but I wonder if it's because the tables are not normalized. I'm not seeing why you need that expression, but perhaps you could post some data from your table(s) to make it clearer. This sort of exercise looks like inventory tracking where (often) one field holds the transactions. If you start with a count of 30 and there are 27 date entries of 1 dose per, then you total the 30 + (27 of -1) which means you have 3 remaining. If you purchase 30 more, you have a dated transaction of 30 for a total of 33.
If you're going to suspend a script, why not simplify the process by not making records for that period? I don't see why it has to be factored into a calculation.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.