I'm not quite sure I understand your code but here's an ides to investigate.
What happen if the user don't open the second modal form or if the user close the second modal form without selecting any record for modification?
You seems to use the same cursor name on both form, maybe try to use different cursor names, if possible.
Good luck.
Diane Robitaille eng.