Instructions in QueryClose event

I have a field SaveOptions (Text, editable) with a default value =“1”.I use this field in below code in the QueryClose event:

Emailbody:=“blablabla.”+ @NewLine +@NewLine +"Please click here → ";

@If(HZIChangesNo=“1” & SaveOptions=“1”;

@If(Compl_1=“Completed”;

@Do(

@SetField(“HZIstatus”;“Submitted”);

@Command([FileSave]);

@SetField (“status”;“4. Completed”);

@Command([FileSave]);

@MailSend(HZIdivmgr;HZIsupv;“”;“Health & Safety - Action Complete - The hazard Investigation of “+HZINum +” has been completed”;Emailbody;“”;[IncludeDoclink]);

@SetField(“SaveOptions”;“0”);

@Command([FileSave]);

@Command([FileCloseWindow])

);“”);

… this goes upto HZIChangesNo=“10”

…;

@If(HZIChangesNo=“10” & SaveOptions=“1”;

@If(Compl_1=“Completed” & Compl_2=“Completed” & Compl_3=“Completed” & Compl_4=“Completed” & Compl_5=“Completed” & Compl_6=“Completed” & Compl_7=“Completed” & Compl_8=“Completed” & Compl_9=“Completed” & Compl_10=“Completed”;

@Do(

@SetField(“HZIstatus”;“Submitted”);

@SetField (“status”;“4. Completed”);

@SetField(“SaveOptions”;“0”);

@MailSend(HZIdivmgr;HZIsupv;“”;"Health & Safety - Action Complete - The hazard

Investigation of “+HZINum +” has been completed";Emailbody;“”;[IncludeDoclink]);

@Command([FileCloseWindow])

);“”);“”))))))))))

It’s the intention that after the first time SaveOptions is put to “0” so that these instructions are only executed once.

Although I put a @command([FileSave]) after each instruction the SaveOptions field returns to value “1” at the end of the event. Consequently the QueryClose event is executed each time the document is closed.

Does anybody have a clue where this is going wrong or where I should have a special look?

Thx

Subject: RE: instructions in QueryClose event

You’re calling [FILESAVE] in the QueryClose… what’s in the [FILESAVE] event?

Perhaps use a different field for the Instructions, i.e. SHOWINST=“1”, instead of SaveOptions which is more commonly used to control if the form values are to be saved.