+ Reply to Thread
Results 1 to 7 of 7

MSG BOX PREVENTS setfocus HELP

  1. #1
    helpless in iowa
    Guest

    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. #2
    swisse
    Guest

    RE: MSG BOX PREVENTS setfocus HELP

    Remove the command Exit Sub.

    Swisse

  3. #3
    helpless in iowa
    Guest

    RE: MSG BOX PREVENTS setfocus HELP

    i have removed that it still dosent work


    "swisse" wrote:

    > Remove the command Exit Sub.
    >
    > Swisse


  4. #4
    Dave Peterson
    Guest

    Re: 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. #5
    helpless in iowa
    Guest

    Re: 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. #6
    swisse
    Guest

    Re: MSG BOX PREVENTS setfocus HELP

    Read my answer at your other post.

    Swisse

  7. #7
    Tom Ogilvy
    Guest

    Re: MSG BOX PREVENTS setfocus HELP

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

    --
    Regards,
    Tom Ogilvy

    "helpless in iowa" <[email protected]> wrote in
    message news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1