Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default A Question for Ron de Bruin

Ron,

I asked a question on 5 Jan regarding exit event of a text
box and getting focus back if the entry did not meet
certain criteria. You kindly answered the question. It
generated a lot of interest from others regarding the
frame control. I aprreciate your help and thank you for
helping.It did help me.

I have now removed the offending frames from the userform.
However, the code below works fine if I remove the Msgbox.
Once the msgbox code is executed the focus is lost to the
msgbox and deos not come back to the textbox.

Is this a known problem or can it be resolved? Thanks so
much for for your help.

Your answer was
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

My original Qs was
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default A Question for Ron de Bruin

Jamal,

You simply forgot to set the Cancel argument

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)
Cancel = True
End If

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default A Question for Ron de Bruin

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


worked fine for me in a userform with two textboxes, a commandbutton and no
frames.

If the user can only enter 100, why not just have your code enter it an be
done with it. (use a label, not a textbox). Unless this is just a
simplified example.

--
Regards,
Tom Ogilvy

"Jamal" wrote in message
...
Ron,

I asked a question on 5 Jan regarding exit event of a text
box and getting focus back if the entry did not meet
certain criteria. You kindly answered the question. It
generated a lot of interest from others regarding the
frame control. I aprreciate your help and thank you for
helping.It did help me.

I have now removed the offending frames from the userform.
However, the code below works fine if I remove the Msgbox.
Once the msgbox code is executed the focus is lost to the
msgbox and deos not come back to the textbox.

Is this a known problem or can it be resolved? Thanks so
much for for your help.

Your answer was
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

My original Qs was
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default A Question for Ron de Bruin

Hi jamal

You see how great this goup is<g
Thanks Bob/Tom

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Jamal" wrote in message ...
Ron,

I asked a question on 5 Jan regarding exit event of a text
box and getting focus back if the entry did not meet
certain criteria. You kindly answered the question. It
generated a lot of interest from others regarding the
frame control. I aprreciate your help and thank you for
helping.It did help me.

I have now removed the offending frames from the userform.
However, the code below works fine if I remove the Msgbox.
Once the msgbox code is executed the focus is lost to the
msgbox and deos not come back to the textbox.

Is this a known problem or can it be resolved? Thanks so
much for for your help.

Your answer was
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

My original Qs was
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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Questioin for Ron de Bruin Jenny B. Excel Discussion (Misc queries) 7 June 19th 08 03:57 PM
question for Ron de Bruin on importing JohnE Excel Discussion (Misc queries) 2 August 23rd 07 01:52 AM
[email protected] Ron de Bruin Excel Discussion (Misc queries) 1 July 21st 05 01:07 PM
For Ron Bruin Please Steved Excel Worksheet Functions 6 April 6th 05 02:19 AM
For Ron de Bruin Please Steved Excel Worksheet Functions 6 March 16th 05 12:46 AM


All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"