FUNCTION QueryUnload LOCAL llresult llresult = .T. IF < some logical condition > * Code to handle it NODEFAULT llresult = .F. ENDIF RETURN llresult ENDFUNC PROCEDURE Command_Click IF ThisForm.QueryUnload() ThisForm.Release ENDIF ENDPROCThis would allow form to handle the closure of the form regardless of the method.