I believe what Gustav mentioned should resolved your issue?
Just in case if it doesn't and you mean to "sum all relevant amount values if its correspondence's field: NotPaidYN = False", then use DSUM function instead.
Personally, I avoid negatives in field and variable names, it just makes them harder to deal with and understand in your code. Instead of [NotPaidYN] I would have used [PaidYN]
Open in new window