Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Text Box exit

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,123
Default Text Box exit

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Text Box exit

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Text Box exit

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Text Box exit

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Text Box exit

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Text Box exit

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










  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Text Box exit

Tom,

I tried that. Problem comes when that frame has more than one textbox, you
don't get the error until the whole frame is tabbed out of, and the focus
stays on the last textbox.

It's a real nasty/

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tom Ogilvy" wrote in message
...
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












  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Text Box exit

It's a real nasty/

MSForms Frames have kind of been like that in general. <g

--
Regards,
Tom Ogilvy


"Bob Phillips" wrote in message
...
Tom,

I tried that. Problem comes when that frame has more than one textbox, you
don't get the error until the whole frame is tabbed out of, and the focus
stays on the last textbox.

It's a real nasty/

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tom Ogilvy" wrote in message
...
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














  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Text Box exit

Woudn't the textbox exit code fire in those cases ?

--
HTH. Best wishes Harald
Followup to newsgroup only please

"Bob Phillips" skrev i melding
...
Tom,

I tried that. Problem comes when that frame has more than one textbox, you
don't get the error until the whole frame is tabbed out of, and the focus
stays on the last textbox.





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Text Box exit

Harald,

Only after you exit the frame, and as I said, it doesn't setfocus to the
first textbox.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Harald Staff" wrote in message
...
Woudn't the textbox exit code fire in those cases ?

--
HTH. Best wishes Harald
Followup to newsgroup only please

"Bob Phillips" skrev i melding
...
Tom,

I tried that. Problem comes when that frame has more than one textbox,

you
don't get the error until the whole frame is tabbed out of, and the

focus
stays on the last textbox.





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
Exit Sub Jeff Excel Discussion (Misc queries) 2 March 1st 08 06:21 PM
Run when exit PH NEWS Excel Worksheet Functions 1 July 18th 06 03:53 PM
exit object Mike Excel Discussion (Misc queries) 4 June 10th 06 07:04 AM
on exit macro ditchy Excel Discussion (Misc queries) 2 May 3rd 05 12:11 AM
Exit Sub? Eva Shanley[_2_] Excel Programming 3 December 24th 03 02:15 PM


All times are GMT +1. The time now is 03:17 PM.

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"