Simon,
Show us the code in the button's click event or in the uload, destroy, release of the form the button is in.
Does the form go away before the error message or does the error message show on top of the form? In other words, we need to isolate the error as to where in the code it is occuring. Is it in the form or in the code after the form.