How to restrict user to close form after validation?

Hi

I want to restrict user to close form after some validation on form.

I tried canClose but it is very first event fired in form sequence when no validation is fired.

Any help

return false or true w.r.t your validation in closed()

thanks for reply, i tried this but still form is getting closed after failing validation

Use a global Boolean variable in the form, Pass the result of validateWrite() into this variable and use this variable to control close in canClose() method

THANKS FOR REPLY…

CanClose event gets filed very 1st in sequence -

CanClose, ValidateWrite,Write,Close

if try to validate in CanClose till then datasource write is not fired. Also how can i exclude ESC key scenario… if user dnt want to save data

I will try to put my requirement

I have 2 table T1 and T2 ( T2 has foreign key relation with T1). Form have both datasources and i want to mandate some fields of T2 (grid) on basis of some field (F1) selection from T1 datasource.

This is achived by putting code (making mandatory )on modify field of T1 datasource but while closing form it is not validating mandatory fileds on T2 datasource.

I want to validate user should at least enter 1 datarow in T2 grid if he has selected F1 from T1 datasource on form.

Just return false in your closed event of the form and print an error box and write the code to revert back the update done in case if validation fails.