Lorenzo,
You can detect a form being closed by its On Close event. If there is a
command button that closes the form and you need to know whetjer that or
the [X] was used, then you can add a hidden control (unbound textbox or
label) to the form's design, and change its value/caption in the first
line of code of the button's Click event; that way, your form's On Close
code can check the value/caption and determine whether the command
button has been clicked or not.
HTH,
Nikos