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

If msg box line is removed from code, text box will be the focus and text
selected. With MSG BOX line left in, its like it just skips the focus and
highlight code

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

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default MSG BOX PREVENTS SET FOCUS POST 2

See one alternative at your other post.

helpless in iowa wrote:

If msg box line is removed from code, text box will be the focus and text
selected. With MSG BOX line left in, its like it just skips the focus and
highlight code

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

End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default MSG BOX PREVENTS SET FOCUS POST 2

Hello helpless in iowa,
I would rather get rid of the message box and use instead a label to get the
attention of the user for example, and I presume that you're using a Userform:
Label2.Visible = True 'alerts the user to enter a numeric value
txtphone.SetFocus
txtphone.SelStart = 0
txtphone.SelLength = 1000
But in the UserForm_Initialize() you have to initialize the Label2.Visible
as False, otherwise it appear when the Userform appears for the first time,
which you won't like.

Swisse

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
MSG BOX PREVENTS setfocus HELP helpless in iowa Excel Programming 6 January 18th 05 12:30 PM


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