View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.programming
Peter Rooney Peter Rooney is offline
external usenet poster
 
Posts: 325
Default Checking the status of a checkbox in a user form

Tom,

Thanks very much for this useful background information (particularly the
bit about the cancel property of all other buttons being set to False when
the cancel property of a button is set to true.

My little app is now working exactly how I want it to,

Thanks for your help

Pete

"Tom Ogilvy" wrote:

Set the cancel property of the control that has code in the click event to
unload or hide the form to True.

Only one CommandButton on a form can be the Cancel button. Setting Cancel to
True for one command button automatically sets it to False for all other
objects on the form. When a CommandButton's Cancel property is set to True
and the form is the active form, the user can choose the command button by
clicking it, pressing ESC, or pressing ENTER when the button has the focus.

A typical use of Cancel is to give the user the option of canceling
uncommitted changes and returning the form to its previous state.

You should consider making the Cancel button the default button for forms
that support operations that can't be undone (such as delete). To do this,
set both Cancel and the Default property to True.

--
Regards,
Tom Ogilvy


"Peter Rooney" wrote in message
...
Jake,

I found it - sorry to be so dim.

Any chance you could refresh my memory as to how to make a userform
disappear when you press the "Escape" key - then I'll get back into my box
for the rest of the day.

Your explanation of MODAL was top notch, by the way. Thanks!

regards

Pete

"Jake Marx" wrote:

Hi Peter,

Peter Rooney wrote:
Fair enough, I won't try to find a complex answer when there's a
simple one there.
In addition, I don't even KNOW what a modal userform is (LOL)
That's how much I know!

Tom's right - if you want to always have initial focus on the button,

then
set its TabIndex property to 0. If you only want to do it in certain
situations, you can do it with SetFocus.

Modal vs. Non-Modal is something you'll need to know about when using
UserForms. Modal means that you Show a UserForm from your code, and
execution will not continue in the calling code until the UserForm is

hidden
or unloaded. Also, the UserForm will take focus, disallowing any
interaction with the workbook. Non-Modal means that the UserForm is
displayed "modelessly" - interaction with the workbook is allowed, and

the
calling code continues to execute.

In your case, since you showed the UserForm modally (no arguments to the
Show method), code will not continue to execute until the UserForm is
dismissed or hidden. So the line of code setting the Default property

to
True for the CancelButton button will not execute until the UserForm is
hidden, which defeats the purpose. You can place this type of code into

the
Initialize event of the UserForm, which will execute when the UserForm

is
first being initialized.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]