Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MSG BOX PREVENTS setfocus HELP

If a letter is enterd into the text box, it sends a msg box to say must be
numeric and then should set focus and highlight last enterd text to change
it. If I remove the msgbox it selects the text box and highlites if the msg
box line is left in it does not select the textbox and does not hightlite
what am i doint wrong thanks in advance:

Private Sub txtphone_Change()
If Not IsNumeric(txtphone) Then
MsgBox "Must be Numeric"
txtphone.SetFocus
txtphone.SelStart = 0
txtphone.SelLength = 1000
Exit Sub
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default MSG BOX PREVENTS setfocus HELP

Remove the command Exit Sub.

Swisse
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default MSG BOX PREVENTS setfocus HELP

i have removed that it still dosent work


"swisse" wrote:

Remove the command Exit Sub.

Swisse

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default MSG BOX PREVENTS setfocus HELP

Maybe you could just validate the textbox when the user tries to leave:

Option Explicit
Private Sub txtphone_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsNumeric(txtphone.value) Then
MsgBox "Must be Numeric"
Cancel = True
End If
End Sub

helpless in iowa wrote:

If a letter is enterd into the text box, it sends a msg box to say must be
numeric and then should set focus and highlight last enterd text to change
it. If I remove the msgbox it selects the text box and highlites if the msg
box line is left in it does not select the textbox and does not hightlite
what am i doint wrong thanks in advance:

Private Sub txtphone_Change()
If Not IsNumeric(txtphone) Then
MsgBox "Must be Numeric"
txtphone.SetFocus
txtphone.SelStart = 0
txtphone.SelLength = 1000
Exit Sub
End If

End Sub


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default MSG BOX PREVENTS setfocus HELP

Thanks, but this does not fix the problem. I still need to set the focus back
to the textbox

"Dave Peterson" wrote:

Maybe you could just validate the textbox when the user tries to leave:

Option Explicit
Private Sub txtphone_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsNumeric(txtphone.value) Then
MsgBox "Must be Numeric"
Cancel = True
End If
End Sub

helpless in iowa wrote:

If a letter is enterd into the text box, it sends a msg box to say must be
numeric and then should set focus and highlight last enterd text to change
it. If I remove the msgbox it selects the text box and highlites if the msg
box line is left in it does not select the textbox and does not hightlite
what am i doint wrong thanks in advance:

Private Sub txtphone_Change()
If Not IsNumeric(txtphone) Then
MsgBox "Must be Numeric"
txtphone.SetFocus
txtphone.SelStart = 0
txtphone.SelLength = 1000
Exit Sub
End If

End Sub


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default MSG BOX PREVENTS setfocus HELP

Read my answer at your other post.

Swisse
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default MSG BOX PREVENTS setfocus HELP

Cancel = True
causes the focus not to leave the textbox.

--
Regards,
Tom Ogilvy

"helpless in iowa" wrote in
message ...
Thanks, but this does not fix the problem. I still need to set the focus

back
to the textbox

"Dave Peterson" wrote:

Maybe you could just validate the textbox when the user tries to leave:

Option Explicit
Private Sub txtphone_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsNumeric(txtphone.value) Then
MsgBox "Must be Numeric"
Cancel = True
End If
End Sub

helpless in iowa wrote:

If a letter is enterd into the text box, it sends a msg box to say

must be
numeric and then should set focus and highlight last enterd text to

change
it. If I remove the msgbox it selects the text box and highlites if

the msg
box line is left in it does not select the textbox and does not

hightlite
what am i doint wrong thanks in advance:

Private Sub txtphone_Change()
If Not IsNumeric(txtphone) Then
MsgBox "Must be Numeric"
txtphone.SetFocus
txtphone.SelStart = 0
txtphone.SelLength = 1000
Exit Sub
End If

End Sub


--

Dave Peterson



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
website prevents excel import web query steven Excel Discussion (Misc queries) 0 March 2nd 10 02:00 PM
Simplifying a formula that prevents negative numbers MZ Excel Discussion (Misc queries) 4 December 8th 09 09:18 AM
Excel prevents XP Pro laptop going on standby expect_ed Excel Discussion (Misc queries) 0 February 19th 08 06:50 PM
what exactly prevents INDIRECT from accessing closed worksheets? z.entropic Excel Worksheet Functions 3 July 24th 07 03:02 PM
Restricting Scroll Prevents Row and Column Choice Colin Hayes Excel Discussion (Misc queries) 3 June 11th 07 12:36 AM


All times are GMT +1. The time now is 07:15 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"