View Single Post
  #11   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

Jake,

This made a lot of sense when I tried it out BUT...
HOW do I put my code in the initialize event of the userform AND
is the correct syntax "CancelButton.setfocus" or "CancelButton.default=true".

So near and yet so far!

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]