Problem with code in onQueryClosePage trigger

Hi everyone,

I have added some code (the lines I added are in bold)in the onQueryClosePage trigger in page 5708 (Get Shipment Lines).

IF CloseAction IN [ACTION::OK,ACTION::LookupOK] THEN
**salesshipline.RESET;**
**CurrPage.SETSELECTIONFILTER(salesshipline);**
**IF salesshipline.FINDFIRST THEN**
**REPEAT**
**IF salesshipline."Num Facture en cours"<>'' THEN**
**ERROR('Ce BL est déja généré dans la Facture %1',salesshipline."Num Facture en cours");**
**UNTIL salesshipline.NEXT=0;**
CreateLines;

When I press escape to quit the page, the error message is displayed again and I am stuck in the page :mrgreen:

What shall I do to be able to quit the page when I press escape???

By the way, the version of NAV I am using is 2013.

This might post twice, but … change IF … THEN statement to IF … THEN BEGIN/END;

To clarify … the original statement was

IF CloseAction IN [ACTION::OK,ACTION::LookupOK] THEN

CreateLines;

Now, you’ve added several lines between the original condition statement and the CreateLines statement. But, since the original condition statement was in the form of IF…THEN, and you haven’t modified it, the condition, if true, will still only run the first command following the condition. If you want the entire block to run conditionally, then you’ll need to wrap all of the commands in a BEGIN/END block.

Hope that makes more sense.