Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to write code so that when the value entered
in a textbox does not meet certain criteria, the text in the textbox is selected for correction by the user. Please see the code below. Once the user presses the tab key the message is displayed but the focus is lost and goes on to the next textbox or next frame if the textbox is the last one in the current frame. I have tried before update and change as well as exit. What am I doing wrong? How can I get it to go back and highlight the textbox with incorrect text/value. Thanks for your help. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then msgbox "You must enter ....." TextBox1.SetFocus TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You must set Cancel to True Jamal
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then Cancel = True MsgBox "You must enter ....." TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End If End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Jamal" wrote in message ... I am trying to write code so that when the value entered in a textbox does not meet certain criteria, the text in the textbox is selected for correction by the user. Please see the code below. Once the user presses the tab key the message is displayed but the focus is lost and goes on to the next textbox or next frame if the textbox is the last one in the current frame. I have tried before update and change as well as exit. What am I doing wrong? How can I get it to go back and highlight the textbox with incorrect text/value. Thanks for your help. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then msgbox "You must enter ....." TextBox1.SetFocus TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ron,
The frame is the problem. The tab out fires the Frame exit event not the textbox exit event. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Ron de Bruin" wrote in message ... You must set Cancel to True Jamal Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then Cancel = True MsgBox "You must enter ....." TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End If End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Jamal" wrote in message ... I am trying to write code so that when the value entered in a textbox does not meet certain criteria, the text in the textbox is selected for correction by the user. Please see the code below. Once the user presses the tab key the message is displayed but the focus is lost and goes on to the next textbox or next frame if the textbox is the last one in the current frame. I have tried before update and change as well as exit. What am I doing wrong? How can I get it to go back and highlight the textbox with incorrect text/value. Thanks for your help. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then msgbox "You must enter ....." TextBox1.SetFocus TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bob
Now I remember it that I have this problem ones. But I can't remember the workeround. I try to find it -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Bob Phillips" wrote in message ... Ron, The frame is the problem. The tab out fires the Frame exit event not the textbox exit event. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Ron de Bruin" wrote in message ... You must set Cancel to True Jamal Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then Cancel = True MsgBox "You must enter ....." TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End If End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Jamal" wrote in message ... I am trying to write code so that when the value entered in a textbox does not meet certain criteria, the text in the textbox is selected for correction by the user. Please see the code below. Once the user presses the tab key the message is displayed but the focus is lost and goes on to the next textbox or next frame if the textbox is the last one in the current frame. I have tried before update and change as well as exit. What am I doing wrong? How can I get it to go back and highlight the textbox with incorrect text/value. Thanks for your help. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then msgbox "You must enter ....." TextBox1.SetFocus TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Ron,
Me neither, other than to get rid of frames<VBG -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Ron de Bruin" wrote in message ... Hi Bob Now I remember it that I have this problem ones. But I can't remember the workeround. I try to find it -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Bob Phillips" wrote in message ... Ron, The frame is the problem. The tab out fires the Frame exit event not the textbox exit event. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Ron de Bruin" wrote in message ... You must set Cancel to True Jamal Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then Cancel = True MsgBox "You must enter ....." TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End If End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Jamal" wrote in message ... I am trying to write code so that when the value entered in a textbox does not meet certain criteria, the text in the textbox is selected for correction by the user. Please see the code below. Once the user presses the tab key the message is displayed but the focus is lost and goes on to the next textbox or next frame if the textbox is the last one in the current frame. I have tried before update and change as well as exit. What am I doing wrong? How can I get it to go back and highlight the textbox with incorrect text/value. Thanks for your help. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then msgbox "You must enter ....." TextBox1.SetFocus TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End Sub |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bob
I found this KB OFF2000: Exit Event for TextBox in a Frame Does Not Run Correctly http://support.microsoft.com/default...34&Product=xlw Me neither, other than to get rid of frames<VBG I think this was my solution then<g -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Bob Phillips" wrote in message ... Hi Ron, Me neither, other than to get rid of frames<VBG -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Ron de Bruin" wrote in message ... Hi Bob Now I remember it that I have this problem ones. But I can't remember the workeround. I try to find it -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Bob Phillips" wrote in message ... Ron, The frame is the problem. The tab out fires the Frame exit event not the textbox exit event. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Ron de Bruin" wrote in message ... You must set Cancel to True Jamal Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then Cancel = True MsgBox "You must enter ....." TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End If End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Jamal" wrote in message ... I am trying to write code so that when the value entered in a textbox does not meet certain criteria, the text in the textbox is selected for correction by the user. Please see the code below. Once the user presses the tab key the message is displayed but the focus is lost and goes on to the next textbox or next frame if the textbox is the last one in the current frame. I have tried before update and change as well as exit. What am I doing wrong? How can I get it to go back and highlight the textbox with incorrect text/value. Thanks for your help. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then msgbox "You must enter ....." TextBox1.SetFocus TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End Sub |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Put similar code in the Frame exit event?
-- Regards, Tom Ogilvy "Bob Phillips" wrote in message ... Hi Ron, Me neither, other than to get rid of frames<VBG -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Ron de Bruin" wrote in message ... Hi Bob Now I remember it that I have this problem ones. But I can't remember the workeround. I try to find it -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Bob Phillips" wrote in message ... Ron, The frame is the problem. The tab out fires the Frame exit event not the textbox exit event. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Ron de Bruin" wrote in message ... You must set Cancel to True Jamal Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then Cancel = True MsgBox "You must enter ....." TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End If End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Jamal" wrote in message ... I am trying to write code so that when the value entered in a textbox does not meet certain criteria, the text in the textbox is selected for correction by the user. Please see the code below. Once the user presses the tab key the message is displayed but the focus is lost and goes on to the next textbox or next frame if the textbox is the last one in the current frame. I have tried before update and change as well as exit. What am I doing wrong? How can I get it to go back and highlight the textbox with incorrect text/value. Thanks for your help. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1.Value < 100 Then msgbox "You must enter ....." TextBox1.SetFocus TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Exit Sub | Excel Discussion (Misc queries) | |||
Run when exit | Excel Worksheet Functions | |||
exit object | Excel Discussion (Misc queries) | |||
on exit macro | Excel Discussion (Misc queries) | |||
Exit Sub? | Excel Programming |