+ Reply to Thread
Results 1 to 16 of 16

Checking the status of a checkbox in a user form

  1. #1
    Peter Rooney
    Guest

    Checking the status of a checkbox in a user form

    Good afternoon!

    I wonder could some clever person confirm that I'm using the correct syntax?

    I have a user form called FolderForm - it contains a number of checkboxes,
    one of which is named "DirectEnttyCheckBox".
    When I show the form, I check the status of the box with
    If DirectEntryCheckBox.Value = xlOn Then
    MsgBox ("Direct Entry")
    'other code...
    End If

    but when I display the form, check the box, and click the OK button (called
    "OKButton", which runs a procedure containing the above code, plus validation
    checking for other checkboxes too) the message "Direct Entry" isn't displayed.

    While I'm on the subject, can anyone also suggest how I set the focus to
    "OKButton"? I tried "OKButton.setfocus" but it didn't make any difference.

    Can anyone see what I'm doing wrong?

    Regards & thanks in advance

    Pete

  2. #2
    Peter Rooney
    Guest

    RE: Checking the status of a checkbox in a user form

    Doh!

    I should have used "True/False" instead of "xlon/xloff"

    Am I correct in thinking that the latter is used for checkboxes embedded in
    a worksheet?

    However, my second question from the previous post still applies. If I don't
    set the "Daeault" property for the OKButton to "True", how can I subsequently
    set the focus to this button?

    Thanks again, and excuse my Homerability (with apologies to anyone called
    Homer, other than Homer S!)


    "Peter Rooney" wrote:

    > Good afternoon!
    >
    > I wonder could some clever person confirm that I'm using the correct syntax?
    >
    > I have a user form called FolderForm - it contains a number of checkboxes,
    > one of which is named "DirectEnttyCheckBox".
    > When I show the form, I check the status of the box with
    > If DirectEntryCheckBox.Value = xlOn Then
    > MsgBox ("Direct Entry")
    > 'other code...
    > End If
    >
    > but when I display the form, check the box, and click the OK button (called
    > "OKButton", which runs a procedure containing the above code, plus validation
    > checking for other checkboxes too) the message "Direct Entry" isn't displayed.
    >
    > While I'm on the subject, can anyone also suggest how I set the focus to
    > "OKButton"? I tried "OKButton.setfocus" but it didn't make any difference.
    >
    > Can anyone see what I'm doing wrong?
    >
    > Regards & thanks in advance
    >
    > Pete


  3. #3
    Tom Ogilvy
    Guest

    Re: Checking the status of a checkbox in a user form

    xlOn is used for checkboxes from the forms toolbar. For your checkboxes,
    use True and False.

    The best way to control movement through a userform is using the tabindex
    property.

    If for some reason you want to violate that order, then setfocus would be
    the principal command to use. If it isn't working, it could be possible
    that other settings/code are interfering. (possibly you use setfocus in an
    event before the normal tabbing has been applied).

    --
    Regards,
    Tom Ogilvy


    "Peter Rooney" <[email protected]> wrote in message
    news:[email protected]...
    > Good afternoon!
    >
    > I wonder could some clever person confirm that I'm using the correct

    syntax?
    >
    > I have a user form called FolderForm - it contains a number of checkboxes,
    > one of which is named "DirectEnttyCheckBox".
    > When I show the form, I check the status of the box with
    > If DirectEntryCheckBox.Value = xlOn Then
    > MsgBox ("Direct Entry")
    > 'other code...
    > End If
    >
    > but when I display the form, check the box, and click the OK button

    (called
    > "OKButton", which runs a procedure containing the above code, plus

    validation
    > checking for other checkboxes too) the message "Direct Entry" isn't

    displayed.
    >
    > While I'm on the subject, can anyone also suggest how I set the focus to
    > "OKButton"? I tried "OKButton.setfocus" but it didn't make any difference.
    >
    > Can anyone see what I'm doing wrong?
    >
    > Regards & thanks in advance
    >
    > Pete




  4. #4
    John
    Guest

    Re: Checking the status of a checkbox in a user form

    Hi Peter,

    Looks like you missed spelt "Entry" (Entty) to me.

    Problem 2 - .SetFocus is right, so are you referencing the right button? try
    "Me.OKButton.SetFocus" if the code is in the form.

    Best regards

    John

    "Peter Rooney" <[email protected]> wrote in message
    news:[email protected]...
    > Good afternoon!
    >
    > I wonder could some clever person confirm that I'm using the correct
    > syntax?
    >
    > I have a user form called FolderForm - it contains a number of checkboxes,
    > one of which is named "DirectEnttyCheckBox".
    > When I show the form, I check the status of the box with
    > If DirectEntryCheckBox.Value = xlOn Then
    > MsgBox ("Direct Entry")
    > 'other code...
    > End If
    >
    > but when I display the form, check the box, and click the OK button
    > (called
    > "OKButton", which runs a procedure containing the above code, plus
    > validation
    > checking for other checkboxes too) the message "Direct Entry" isn't
    > displayed.
    >
    > While I'm on the subject, can anyone also suggest how I set the focus to
    > "OKButton"? I tried "OKButton.setfocus" but it didn't make any difference.
    >
    > Can anyone see what I'm doing wrong?
    >
    > Regards & thanks in advance
    >
    > Pete




  5. #5
    Peter Rooney
    Guest

    Re: Checking the status of a checkbox in a user form

    John,

    Thanks for pointing out the typo:-)
    Still having trouble with the setfocus. I tried this, too

    Sub ComplexBrowse() '[Control]+[Shift]+C
    Load FolderForm
    FolderForm.Show
    FolderForm.CancelButton.Default = True
    End Sub

    and that doesn't work either (although it doewsn't throw up an error message)

    Still stuck, I'm afraid - where precisely should Me.OKButton.SetFocus go?


    "John" wrote:

    > Hi Peter,
    >
    > Looks like you missed spelt "Entry" (Entty) to me.
    >
    > Problem 2 - .SetFocus is right, so are you referencing the right button? try
    > "Me.OKButton.SetFocus" if the code is in the form.
    >
    > Best regards
    >
    > John
    >
    > "Peter Rooney" <[email protected]> wrote in message
    > news:[email protected]...
    > > Good afternoon!
    > >
    > > I wonder could some clever person confirm that I'm using the correct
    > > syntax?
    > >
    > > I have a user form called FolderForm - it contains a number of checkboxes,
    > > one of which is named "DirectEnttyCheckBox".
    > > When I show the form, I check the status of the box with
    > > If DirectEntryCheckBox.Value = xlOn Then
    > > MsgBox ("Direct Entry")
    > > 'other code...
    > > End If
    > >
    > > but when I display the form, check the box, and click the OK button
    > > (called
    > > "OKButton", which runs a procedure containing the above code, plus
    > > validation
    > > checking for other checkboxes too) the message "Direct Entry" isn't
    > > displayed.
    > >
    > > While I'm on the subject, can anyone also suggest how I set the focus to
    > > "OKButton"? I tried "OKButton.setfocus" but it didn't make any difference.
    > >
    > > Can anyone see what I'm doing wrong?
    > >
    > > Regards & thanks in advance
    > >
    > > Pete

    >
    >
    >


  6. #6
    Peter Rooney
    Guest

    Re: Checking the status of a checkbox in a user form

    Tom,

    Perhaps I'm not asking for the right thing. When the userform is displayed,
    I want to set the focus to the OK button without having to set its "Dafault"
    property to TRUE. I know I COULD do it that way, but I wan't to know if it IS
    possible to set the focus to other command buttons, should the need arise in
    future. I don't have any other setfocus commands in my code.

    Regards

    Pete

    "Tom Ogilvy" wrote:

    > xlOn is used for checkboxes from the forms toolbar. For your checkboxes,
    > use True and False.
    >
    > The best way to control movement through a userform is using the tabindex
    > property.
    >
    > If for some reason you want to violate that order, then setfocus would be
    > the principal command to use. If it isn't working, it could be possible
    > that other settings/code are interfering. (possibly you use setfocus in an
    > event before the normal tabbing has been applied).
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Peter Rooney" <[email protected]> wrote in message
    > news:[email protected]...
    > > Good afternoon!
    > >
    > > I wonder could some clever person confirm that I'm using the correct

    > syntax?
    > >
    > > I have a user form called FolderForm - it contains a number of checkboxes,
    > > one of which is named "DirectEnttyCheckBox".
    > > When I show the form, I check the status of the box with
    > > If DirectEntryCheckBox.Value = xlOn Then
    > > MsgBox ("Direct Entry")
    > > 'other code...
    > > End If
    > >
    > > but when I display the form, check the box, and click the OK button

    > (called
    > > "OKButton", which runs a procedure containing the above code, plus

    > validation
    > > checking for other checkboxes too) the message "Direct Entry" isn't

    > displayed.
    > >
    > > While I'm on the subject, can anyone also suggest how I set the focus to
    > > "OKButton"? I tried "OKButton.setfocus" but it didn't make any difference.
    > >
    > > Can anyone see what I'm doing wrong?
    > >
    > > Regards & thanks in advance
    > >
    > > Pete

    >
    >
    >


  7. #7
    Tom Ogilvy
    Guest

    Re: Checking the status of a checkbox in a user form

    If you want it to happend when the userform is opened, then set the tabindex
    property of that button to zero.

    Setting the default property to zero would have no effect on focus. It
    executes the click event if you hit enter in the form.

    --
    Regards,
    Tom Ogilvy


    "Peter Rooney" <[email protected]> wrote in message
    news:[email protected]...
    > Tom,
    >
    > Perhaps I'm not asking for the right thing. When the userform is

    displayed,
    > I want to set the focus to the OK button without having to set its

    "Dafault"
    > property to TRUE. I know I COULD do it that way, but I wan't to know if it

    IS
    > possible to set the focus to other command buttons, should the need arise

    in
    > future. I don't have any other setfocus commands in my code.
    >
    > Regards
    >
    > Pete
    >
    > "Tom Ogilvy" wrote:
    >
    > > xlOn is used for checkboxes from the forms toolbar. For your

    checkboxes,
    > > use True and False.
    > >
    > > The best way to control movement through a userform is using the

    tabindex
    > > property.
    > >
    > > If for some reason you want to violate that order, then setfocus would

    be
    > > the principal command to use. If it isn't working, it could be possible
    > > that other settings/code are interfering. (possibly you use setfocus in

    an
    > > event before the normal tabbing has been applied).
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Peter Rooney" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Good afternoon!
    > > >
    > > > I wonder could some clever person confirm that I'm using the correct

    > > syntax?
    > > >
    > > > I have a user form called FolderForm - it contains a number of

    checkboxes,
    > > > one of which is named "DirectEnttyCheckBox".
    > > > When I show the form, I check the status of the box with
    > > > If DirectEntryCheckBox.Value = xlOn Then
    > > > MsgBox ("Direct Entry")
    > > > 'other code...
    > > > End If
    > > >
    > > > but when I display the form, check the box, and click the OK button

    > > (called
    > > > "OKButton", which runs a procedure containing the above code, plus

    > > validation
    > > > checking for other checkboxes too) the message "Direct Entry" isn't

    > > displayed.
    > > >
    > > > While I'm on the subject, can anyone also suggest how I set the focus

    to
    > > > "OKButton"? I tried "OKButton.setfocus" but it didn't make any

    difference.
    > > >
    > > > Can anyone see what I'm doing wrong?
    > > >
    > > > Regards & thanks in advance
    > > >
    > > > Pete

    > >
    > >
    > >




  8. #8
    Tom Ogilvy
    Guest

    Re: Checking the status of a checkbox in a user form

    Use the tabindex property. That is what it is there for.

    In addition,
    If your userform is modal, the
    FolderForm.CancelButton.Default = True

    hasn't even executed when the form is shown.
    --
    Regards,
    Tom Ogilvy


    "Peter Rooney" <[email protected]> wrote in message
    news:[email protected]...
    > John,
    >
    > Thanks for pointing out the typo:-)
    > Still having trouble with the setfocus. I tried this, too
    >
    > Sub ComplexBrowse() '[Control]+[Shift]+C
    > Load FolderForm
    > FolderForm.Show
    > FolderForm.CancelButton.Default = True
    > End Sub
    >
    > and that doesn't work either (although it doewsn't throw up an error

    message)
    >
    > Still stuck, I'm afraid - where precisely should Me.OKButton.SetFocus go?
    >
    >
    > "John" wrote:
    >
    > > Hi Peter,
    > >
    > > Looks like you missed spelt "Entry" (Entty) to me.
    > >
    > > Problem 2 - .SetFocus is right, so are you referencing the right button?

    try
    > > "Me.OKButton.SetFocus" if the code is in the form.
    > >
    > > Best regards
    > >
    > > John
    > >
    > > "Peter Rooney" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Good afternoon!
    > > >
    > > > I wonder could some clever person confirm that I'm using the correct
    > > > syntax?
    > > >
    > > > I have a user form called FolderForm - it contains a number of

    checkboxes,
    > > > one of which is named "DirectEnttyCheckBox".
    > > > When I show the form, I check the status of the box with
    > > > If DirectEntryCheckBox.Value = xlOn Then
    > > > MsgBox ("Direct Entry")
    > > > 'other code...
    > > > End If
    > > >
    > > > but when I display the form, check the box, and click the OK button
    > > > (called
    > > > "OKButton", which runs a procedure containing the above code, plus
    > > > validation
    > > > checking for other checkboxes too) the message "Direct Entry" isn't
    > > > displayed.
    > > >
    > > > While I'm on the subject, can anyone also suggest how I set the focus

    to
    > > > "OKButton"? I tried "OKButton.setfocus" but it didn't make any

    difference.
    > > >
    > > > Can anyone see what I'm doing wrong?
    > > >
    > > > Regards & thanks in advance
    > > >
    > > > Pete

    > >
    > >
    > >




  9. #9
    Peter Rooney
    Guest

    Re: Checking the status of a checkbox in a user form

    Tom,

    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!

    Cheers and thanks for your time.

    Pete



    "Tom Ogilvy" wrote:

    > Use the tabindex property. That is what it is there for.
    >
    > In addition,
    > If your userform is modal, the
    > FolderForm.CancelButton.Default = True
    >
    > hasn't even executed when the form is shown.
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Peter Rooney" <[email protected]> wrote in message
    > news:[email protected]...
    > > John,
    > >
    > > Thanks for pointing out the typo:-)
    > > Still having trouble with the setfocus. I tried this, too
    > >
    > > Sub ComplexBrowse() '[Control]+[Shift]+C
    > > Load FolderForm
    > > FolderForm.Show
    > > FolderForm.CancelButton.Default = True
    > > End Sub
    > >
    > > and that doesn't work either (although it doewsn't throw up an error

    > message)
    > >
    > > Still stuck, I'm afraid - where precisely should Me.OKButton.SetFocus go?
    > >
    > >
    > > "John" wrote:
    > >
    > > > Hi Peter,
    > > >
    > > > Looks like you missed spelt "Entry" (Entty) to me.
    > > >
    > > > Problem 2 - .SetFocus is right, so are you referencing the right button?

    > try
    > > > "Me.OKButton.SetFocus" if the code is in the form.
    > > >
    > > > Best regards
    > > >
    > > > John
    > > >
    > > > "Peter Rooney" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > Good afternoon!
    > > > >
    > > > > I wonder could some clever person confirm that I'm using the correct
    > > > > syntax?
    > > > >
    > > > > I have a user form called FolderForm - it contains a number of

    > checkboxes,
    > > > > one of which is named "DirectEnttyCheckBox".
    > > > > When I show the form, I check the status of the box with
    > > > > If DirectEntryCheckBox.Value = xlOn Then
    > > > > MsgBox ("Direct Entry")
    > > > > 'other code...
    > > > > End If
    > > > >
    > > > > but when I display the form, check the box, and click the OK button
    > > > > (called
    > > > > "OKButton", which runs a procedure containing the above code, plus
    > > > > validation
    > > > > checking for other checkboxes too) the message "Direct Entry" isn't
    > > > > displayed.
    > > > >
    > > > > While I'm on the subject, can anyone also suggest how I set the focus

    > to
    > > > > "OKButton"? I tried "OKButton.setfocus" but it didn't make any

    > difference.
    > > > >
    > > > > Can anyone see what I'm doing wrong?
    > > > >
    > > > > Regards & thanks in advance
    > > > >
    > > > > Pete
    > > >
    > > >
    > > >

    >
    >
    >


  10. #10
    Jake Marx
    Guest

    Re: Checking the status of a checkbox in a user form

    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]



  11. #11
    Peter Rooney
    Guest

    Re: 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]
    >
    >
    >


  12. #12
    Peter Rooney
    Guest

    Re: Checking the status of a checkbox in a user form

    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]
    >
    >
    >


  13. #13
    Tom Ogilvy
    Guest

    Re: Checking the status of a checkbox in a user form

    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" <[email protected]> wrote in message
    news:[email protected]...
    > 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]
    > >
    > >
    > >




  14. #14
    Jake Marx
    Guest

    Re: Checking the status of a checkbox in a user form

    Hi Peter,

    Peter Rooney wrote:
    > 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.


    The easiest way is to drop a "Cancel" CommandButton on the UserForm. Just
    set its Cancel property to True, and it will respond to the ESC key.

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


    No problem - glad it helped!

    --
    Regards,

    Jake Marx
    www.longhead.com


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



  15. #15
    Peter Rooney
    Guest

    Re: Checking the status of a checkbox in a user form

    Jake,

    This worked a treat.

    Thanks very much!

    Pete



    "Jake Marx" wrote:

    > Hi Peter,
    >
    > Peter Rooney wrote:
    > > 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.

    >
    > The easiest way is to drop a "Cancel" CommandButton on the UserForm. Just
    > set its Cancel property to True, and it will respond to the ESC key.
    >
    > > Your explanation of MODAL was top notch, by the way. Thanks!

    >
    > No problem - glad it helped!
    >
    > --
    > Regards,
    >
    > Jake Marx
    > www.longhead.com
    >
    >
    > [please keep replies in the newsgroup - email address unmonitored]
    >
    >
    >


  16. #16
    Peter Rooney
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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]
    > > >
    > > >
    > > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1