How do I catch the X button on a user form

A

Alan Silver

Hello,

I have a user form that is designed to ensure that docs started from a
specific template always have a current Outlook appointment item
associated with them. I do this by having code in Document_Close and
checking that a calendar item exists. If it doesn't, or is out of date,
they are prompted for details with the user form.

I have got the code working fine for this now, except for the fact that
if the user clicks on the X button on the form, the form is closed, and
I can't see any way to tell if this is happening in the code.

So, two questions ...

1) can I get rid of or disable the X button ? I know this is not
normally a good idea, but in this case the client specifically wants
that the user has to enter valid info before closing the document.

2) (kind of dependent on the first question) how can I tell if the X
button has been closed ? The Terminate event is fired, but this happens
if the form is closed by me from the code. Assuming I can't remove or
disable the X button, how do I get round the problem ?

Thanx for any help
 
A

Alan Silver

Jezebel said:
Use the form's QueryClose event.

Thanx. About five minutes after posting I spotted that one !! Funny how
you get a clarity after posting ;-)
 
J

Jezebel

Nothing like a sentence of death to clarify one's thinking.



Alan Silver said:
Jezebel said:
Use the form's QueryClose event.

Thanx. About five minutes after posting I spotted that one !! Funny how
you get a clarity after posting ;-)
 
A

Alan Silver

Jezebel said:
Nothing like a sentence of death to clarify one's thinking.

I shudder at the thought that some Internet Overlord might one day
introduce the death penalty for posting a RTM question.

On the one hand, it would reduce the number of questions that could have
been answered in a few minutes by a Google search, but on the other hand
it would be fatal for sleepy old dozers like me who can't see the wood
for the trees !!

Ta ra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top