Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ive been trying to write a routine to prevent empty textboxes. Im using the
TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) event. But since I disabled the close button and using a CommandButton instead; if the user doesnt make any entry at all, itll still trigger the error message when closing the form. Is there a way around it. Can I cancel the cancel event while closing the form from the CommandButton? I cant retain the focus on the control. I also tried the BeforeUpdate event but didnt get the expected results. Do you know of any good source of related documentation? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Public bBlockEvents as Boolean
Private Sub Textbox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) if bBlockEvents then exit sub End sub Sub CmdExit_Click() bBlockEvents = True end Sub so use a public variable in the userform module to indicate your intention and exercise control. -- Regards, Tom Ogilvy "LuisE" wrote: Ive been trying to write a routine to prevent empty textboxes. Im using the TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) event. But since I disabled the close button and using a CommandButton instead; if the user doesnt make any entry at all, itll still trigger the error message when closing the form. Is there a way around it. Can I cancel the cancel event while closing the form from the CommandButton? I cant retain the focus on the control. I also tried the BeforeUpdate event but didnt get the expected results. Do you know of any good source of related documentation? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Just adding without ignoring Tom's code: Private Sub CommandButton1_Click() If TextBox1 = "" Then TextBox1.SetFocus: Exit Sub Unload Me End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1 = "" Then Cancel = True End Sub -- Regards, Halim "LuisE" wrote: Ive been trying to write a routine to prevent empty textboxes. Im using the TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) event. But since I disabled the close button and using a CommandButton instead; if the user doesnt make any entry at all, itll still trigger the error message when closing the form. Is there a way around it. Can I cancel the cancel event while closing the form from the CommandButton? I cant retain the focus on the control. I also tried the BeforeUpdate event but didnt get the expected results. Do you know of any good source of related documentation? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Once Again Thank you
"Tom Ogilvy" wrote: Public bBlockEvents as Boolean Private Sub Textbox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) if bBlockEvents then exit sub End sub Sub CmdExit_Click() bBlockEvents = True end Sub so use a public variable in the userform module to indicate your intention and exercise control. -- Regards, Tom Ogilvy "LuisE" wrote: Ive been trying to write a routine to prevent empty textboxes. Im using the TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) event. But since I disabled the close button and using a CommandButton instead; if the user doesnt make any entry at all, itll still trigger the error message when closing the form. Is there a way around it. Can I cancel the cancel event while closing the form from the CommandButton? I cant retain the focus on the control. I also tried the BeforeUpdate event but didnt get the expected results. Do you know of any good source of related documentation? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
MACRO: Selecting "Cancel" from a drop down to copy and paste entirerow to another sheet | Excel Discussion (Misc queries) | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
"cancel" caption doesn't show up on cancel dialog | Excel Programming | |||
how to stop program with loop by click "Cancel" button | Excel Programming | |||
Close workbook with "Cancel=TRUE" in the BeforeClose()" | Excel Programming |