Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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" wrote in message ... 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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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" wrote in message ... 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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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" wrote in message ... 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" wrote in message ... 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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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" wrote in message ... 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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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" wrote in message ... 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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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" wrote in message ... 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" wrote in message ... 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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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" wrote in message ... 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" wrote in message ... 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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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] |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
conditional adding by checking status | Excel Discussion (Misc queries) | |||
Clear a Checkbox in a a user form | Excel Discussion (Misc queries) | |||
Checking Protect status | Excel Programming | |||
Status Message User Form in Excel '97 | Excel Programming | |||
creating a checkbox control on a user form using VBA | Excel Programming |