+ Reply to Thread
Results 1 to 5 of 5

keep focus on textbox

  1. #1
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2016
    Posts
    187

    keep focus on textbox

    Hi
    I want the user to enter numeric value or nothing into a textbox.
    If it is not the case,then I want to keep the focus on the textbox.
    The code I wrote works fine, but the focus moves to other element. What do I do incorrectly?
    I tried the afterUpdate event, bit it didn't help.
    Thank you

    Please Login or Register  to view this content.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: keep focus on textbox

    Instead of Me.txtEUR.SetFocus, just use:

    Please Login or Register  to view this content.
    Rory

  3. #3
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2016
    Posts
    187

    Re: keep focus on textbox

    Thanks
    And before or the afterevent is the right approach?

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: keep focus on textbox

    BeforeUpdate is more appropriate, and AfterUpdate doesn't have a Cancel parameter.

  5. #5
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2016
    Posts
    187

    Re: keep focus on textbox

    Many thanks for the help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Textbox doesnt automatically regain focus until textbox entered
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-12-2019, 12:35 PM
  2. [SOLVED] Pressing Enter on Textbox moves focus to next Textbox
    By Bezzie in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-11-2016, 09:37 AM
  3. textbox without focus
    By eugz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2014, 04:24 PM
  4. Focus on Textbox
    By seemanthv in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2014, 02:38 AM
  5. [SOLVED] Textbox focus
    By tradinup2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-08-2013, 12:25 AM
  6. setting focus on a textbox
    By Geordie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-08-2010, 12:26 PM
  7. How to tell what textbox got the focus
    By vqthomf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2005, 09:15 AM

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