AR Remove Zero Balance Invoices - Error 27 & Error 11

Error 27: Unexpected or incorrect WEND, RETURN, WITH or NEXT. Line 02006, 00040, & 00125
Error 11: Record not found or Duplicate key on write. Line 00188

AR_REMOVEZEROBALINVOICES_UI

Customer received this error while trying to remove old AR invoices. Any idea why or how to correct?

Sage 100 Std v2016