+ Reply to Thread
Results 1 to 4 of 4

AfterUpdate/BeforeUpdate and SetFocus

Hybrid View

  1. #1
    Registered User
    Join Date
    05-05-2010
    Location
    Den Haag, Nederland
    MS-Off Ver
    Excel 2007
    Posts
    3

    AfterUpdate/BeforeUpdate and SetFocus

    I have some problems with the SetFocus command in a Userform with an AfterUpdate or BeforeUpdate routine.

    To make it clear to you, I made a very small Userform to demonstrate it. It only contains 8 TextBoxes and this code:
    Private Sub TextBox01_AfterUpdate()
    Me.TextBox08.SetFocus
    End Sub
    -
    Private Sub TextBox02_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox08.SetFocus
    End Sub
    -
    Private Sub TextBox03_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox08.SetFocus
    End Sub
    -
    Private Sub TextBox04_Change()
    TextBox08.SetFocus
    End Sub
    I expected that in all cases, the focus should be set to TextBox08, but this only happens with the Change event.

    Do you have any suggestions how I can set the focus to TextBox08 in an AfterUpdate or BeforeUpdate event?

    I use Excel 2007

    Kind regards,

    Otto.
    Last edited by Leith Ross; 05-05-2010 at 01:02 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: AfterUpdate/BeforeUpdate and SetFocus

    Hello odekkers,

    Welcome to the Forum!

    As a new member of the forum, please take a few minutes and read the forum rules for posting and general etiquette. To see them, click on the link below...

    Forum Rules
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: AfterUpdate/BeforeUpdate and SetFocus

    Hello Otto,

    Try this trick, it works in Excel 2003...
    Private Sub TextBox01_AfterUpdate()
    TextBox08.Value = TextBox08.Text
    Me.TextBox08.SetFocus
    End Sub
    -
    Private Sub TextBox02_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox08.SetFocus
    End Sub
    -
    Private Sub TextBox03_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox08.Value = TextBox08.Text
    TextBox08.SetFocus
    End Sub
    -
    Private Sub TextBox04_Change()
    TextBox08.Value = TextBox08.Text
    TextBox08.SetFocus
    End Sub

  4. #4
    Registered User
    Join Date
    05-05-2010
    Location
    Den Haag, Nederland
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: AfterUpdate/BeforeUpdate and SetFocus

    Hello Leith,

    Thank you for helping me posting mu question correctly, and for you quick answer. But I'm sorry, your trick didn't make any difference.

    Kind regards,
    Otto.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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