OK... this may not be correct but this is what I uderstand. You have a form that has a close button.
The close button first unloads the for it's on and then
executes other commands?

If this is the case, I'd think it was your problem. Your command button is part of the form, and you're unloading the form.. but there's more code after it to execute. So it really can't unload.

If you need to make the form not visable before you execute this other code, hide it first, then execute your code, then unload it. If not, execute your code first, then the last thing in that event should be the unload.

Sorry if this answer doesn't refelect the functionality in your program. It's what I interpreted and I thought I'd write an asnwer to it instead of asking if I was correct first