ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm_QueryClose questions (https://www.excelbanter.com/excel-programming/325991-userform_queryclose-questions.html)

Don Wiss

UserForm_QueryClose questions
 
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).

Bob Phillips[_6_]

UserForm_QueryClose questions
 
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)


"Don Wiss" wrote in message
...
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).




Bob Phillips[_6_]

UserForm_QueryClose questions
 
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)


"Don Wiss" wrote in message
...
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).





All times are GMT +1. The time now is 06:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com