UserForm_QueryClose questions

D

Don Wiss

Behind my user form I have a UserForm_QueryClose macro. This as I would
like people to confirm when they press the Escape key. I want them to
realize they will be closing the form and not saving any changes to their
input data. If I set the Cancel property on my cancel button to False, then
the escape key is not allowed. If I set it to True, escape works, the
UserForm_QueryClose macro is called, but I can't tell that an escape was
pressed instead of the Cancel button being clicked.

What I observe is when escape is pressed, or the done or cancel buttons are
clicked (all are doing unloads), inside the macro Cancel=0 and CloseMode=1.
If the X in the upper right of the form is clicked, Cancel=0 and
CloseMode=0. Is there any other more useful information that can be
accessed so I can do what I want? I suspect not. (When does Cancel=1?)

Don <www.donwiss.com> (e-mail link at home page bottom).
 
B

Bob Phillips

From help, the values for closemode

vbFormControlMenu 0 The user has chosen the Close command from the
Control menu on the UserForm.
vbFormCode 1 The Unload statement is invoked from code.
vbAppWindows 2 The current Windows operating environment session is
ending.
vbAppTaskManager 3 The Windows Task Manager is closing the
application.


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
B

Bob Phillips

BTW, Cancel is an argument that you determine the value (true or False)
depending upon whether you want to continue the Cancel or quit it. It should
always enter False.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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