+ Reply to Thread
Results 1 to 3 of 3

TextBox1.SetFocus not responding

  1. #1
    excelnut1954
    Guest

    TextBox1.SetFocus not responding

    This is probably something too simple....

    As you can see below, I have put this line of code everywhere I can
    think of. But, TextBox2 still comes up active. I even tried
    UserForm4.TextBox1.SetFocus with no better results. Can anyone spot my
    obvious error???
    Thanks,
    J.O.


    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    'This will check to make sure the PO# the user entered is not already
    on
    'the list. If so, message box comes up.

    With Worksheets("Official list")

    'TextBox1.SetFocus

    If TextBox1.Text <> "" And Not .Range("j:j").Find(TextBox1.Text,
    LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False) Is Nothing Then
    MsgBox "This PO/PL is already on the list. Please enter the
    information in the existing Record."

    'This will clear all testboxes
    For Each ctl In Me.Controls
    If TypeName(ctl) = "TextBox" Then
    ctl.Text = ""
    'TextBox1.SetFocus

    End If
    Next ctl

    'TextBox1.SetFocus

    End If
    End With

    'TextBox1.SetFocus


    End Sub


  2. #2
    Harald Staff
    Guest

    Re: TextBox1.SetFocus not responding

    Hi JO

    Not simple at all. MsgBox'es conflict with setfocus in exit events. I don't
    have any other solution than putting the message somewhere else, like onto a
    label next to the box. It should be obvious enough, msgboxes are also
    extremely annoying when you do keyboard entries.

    HTH. Best wishes Harald

    "excelnut1954" <excelnut1954@yahoo.com> skrev i melding
    news:1149013754.477538.248890@38g2000cwa.googlegroups.com...
    > This is probably something too simple....
    >
    > As you can see below, I have put this line of code everywhere I can
    > think of. But, TextBox2 still comes up active. I even tried
    > UserForm4.TextBox1.SetFocus with no better results. Can anyone spot my
    > obvious error???
    > Thanks,
    > J.O.
    >
    >
    > Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    > 'This will check to make sure the PO# the user entered is not already
    > on
    > 'the list. If so, message box comes up.
    >
    > With Worksheets("Official list")
    >
    > 'TextBox1.SetFocus
    >
    > If TextBox1.Text <> "" And Not .Range("j:j").Find(TextBox1.Text,
    > LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False) Is Nothing Then
    > MsgBox "This PO/PL is already on the list. Please enter the
    > information in the existing Record."
    >
    > 'This will clear all testboxes
    > For Each ctl In Me.Controls
    > If TypeName(ctl) = "TextBox" Then
    > ctl.Text = ""
    > 'TextBox1.SetFocus
    >
    > End If
    > Next ctl
    >
    > 'TextBox1.SetFocus
    >
    > End If
    > End With
    >
    > 'TextBox1.SetFocus
    >
    >
    > End Sub
    >




  3. #3
    excelnut1954
    Guest

    Re: TextBox1.SetFocus not responding

    Thanks.
    I think I'll just have it go to another UF instead of the MsgBox.
    Thanks for the info.
    J.O.


+ 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