Preventing from closing the page if a field isn't filled


Hi everyone,

I have a list page with several columns and an OK button.
I need to do the following: If column A is not filled by the user then he shouldn’t be able to close the apge.
Here is the code I’ve written so far:



IF PAGE.RUNMODAL(PageX,RecX) = ACTION::LookupOK THEN BEGIN
//SOME CODE HERE that
IF (fieldXXX= TRUE) THEN ERROR(TextXX);
//SOME OTHER CODE HERE
END;



The problem with that code is that the user is still able to close the page and after that the error message appears.
How can I correct that to get the behaviour I want?

Thanks in advance :mrgreen: